# Invoke Code throwing compiling errors during method declaration

**URL:** <https://forum.uipath.com/t/invoke-code-throwing-compiling-errors-during-method-declaration/363609>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, system, activities\
**Created:** [November 22, 2021, 2:23pm UTC](https://forum.uipath.com/t/invoke-code-throwing-compiling-errors-during-method-declaration/363609 "2021-11-22T14:23:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![salladinne](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/salladinne/32/176935_2.png) [@salladinne](https://forum.uipath.com/u/salladinne)\
**Post date:** [November 22, 2021, 2:23pm UTC](https://forum.uipath.com/t/invoke-code-throwing-compiling-errors-during-method-declaration/363609/1 "2021-11-22T14:23:49Z")

</div>

Hi Team, I am having troubles with translating working code in Visual Studio to Invoke code in UiPath.

I am trying to set up a method for checking file name (input) in zip folder (input) and if it’s there, return true, if not - false (output arg)

This is my code:

```auto
public bool ReturnZipName (string fileName, string folderName)
{
    using (ZipArchive archive = ZipFile.OpenRead(folderName))
    {
        

        foreach (ZipArchiveEntry entry in archive.Entries)
        {
            if (entry.Name == fileName)
            {
                return true;
            }
                      
        }
        return false;
    }
}

zipFileFound = ReturnZipName(@"FinInvoiceRegisters_20190617193130.csv", @"C:\Users\emea_svc_ibot_bsot01\OneDrive - CBRE, Inc\Documents\UiPath\ES_PMA_APInvoice\Testing\c# test\11_Transfer_20190617_193130.zip");

```

This is list of my arguments

 ![image](https://global.discourse-cdn.com/uipath/original/4X/d/f/f/dffbc57111e3e25eb624df5697eac24a4ba6d99a.png)

This is the errors I am getting:

```auto
test.xaml: No compiled code to run
error CS1513: } expected At line -1
error CS1519: Invalid token '=' in class, struct, or interface member declaration At line 18
error CS1520: Method must have a return type At line 18
error CS1031: Type expected At line 18
error CS1022: Type or namespace definition, or end-of-file expected At line 20

```

Can anyone help?

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [November 22, 2021, 3:12pm UTC](https://forum.uipath.com/t/invoke-code-throwing-compiling-errors-during-method-declaration/363609/2 "2021-11-22T15:12:47Z")

</div>

Hi @salladinne ,

We do not really need to define a function or a class to inside Invoke Code to achieve the desired Output as we do in Visual Studio.

Invoke Code Lets us use the Code directly. Although Assembly references would need to be added.

In this case, the System.IO.Compression needs to be Imported through the Imports Panel  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/8/3/f/83f8701e521323cdca764272d9fcaa767013bfe4.png)

Use this minimal Code in Invoke Code Activity and Let us know if it Works.

```auto
using (ZipArchive archive = ZipFile.OpenRead(folderName))
{
	zipFileFound = false;
        foreach (ZipArchiveEntry entry in archive.Entries)
        {
            if (entry.Name == fileName)
                zipFileFound = true;
                      
        }
 }

```

`fileName` and `folderName` are passed as in arguments and `zipFileFound` is an out argument.

Also Please Note, the `Language` Property of Invoke Code Activity should be set to `CSharp`

---

<div class="post-metadata">

**Author:** ![salladinne](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/salladinne/32/176935_2.png) [@salladinne](https://forum.uipath.com/u/salladinne)\
**Post date:** [November 22, 2021, 7:03pm UTC](https://forum.uipath.com/t/invoke-code-throwing-compiling-errors-during-method-declaration/363609/3 "2021-11-22T19:03:13Z")

</div>

Yes, thank you, it worked!  
Although it does bother me a bit that there is no way to call a full C# script in UiPath if I do want to make use of methods, classes and more advanced concepts?

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [November 25, 2021, 7:03pm UTC](https://forum.uipath.com/t/invoke-code-throwing-compiling-errors-during-method-declaration/363609/4 "2021-11-25T19:03:41Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
