Extract and execute a foreach loop resource c#

Asked

Viewed 30 times

2

private string GetDialogs()
        {
            string temp = Path.Combine(Directory.GetCurrentDirectory(), "dlgs.exe");

            using FileStream stream = new(temp, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
            byte[] bytes = Properties.Resources.GetDialogsApp();

            stream.Write(bytes, 0, bytes.Length);

            return temp;
        }

public string Dialogs => GetDialogs();

I use the above instantiated code. Within the loop I use the "_app. Dialogs" to point to the "dlgs,exe" and extract text from files using "Process.Start". But it’s extracting the . exe for every iteration of the file list and I want to avoid that. If use "Filemode.Createnew" causes exception that file exists with same name. If use "Fileshare.Readwrite." the . exe is rewritten for each iteration of the list.

How can I declare the Resource to be extracted once and used by all files in the list?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.