In the following code how to fix problem that the batch file won't get created. When I run in debug mode exception I get is "could not find part of path"

Thanks

StreamWriter sw = null;

            try
            {
                if (AgilentNVisaDriver.Checked == false && RequiredDlls.Checked == false)
                {
                    MessageBox.Show("Please select the application you would like to install");
                }
                else
                {
                    Assembly objAssembly = Assembly.GetAssembly(this.GetType());
                    string strAppPath = objAssembly.CodeBase;
                    strAppPath = strAppPath.Replace("SplashScreen.dll", "");
                    Uri objUri = new Uri(strAppPath);
                    strAppPath = @objUri.AbsolutePath;

                    string strBatchFilePath = strAppPath + @"Setup.bat";

                    sw = File.CreateText(strBatchFilePath);

You might be having a similar issue as described in this link.

Reply # 2 on that link outlines how to resolve that issue if that's the case.

It seems in the case of the link above the absolute path was so long (due to subdirectories and such) that it exceeded the maximum number of chars for the file path.

Hope this helps :) Please remember to mark as solved if your issue is resolved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.