You can use the
System.IO
namespace and the
Directory.Exists
method to check if a directory is there.
Example:
using System.IO;
if(Directory.Exists(@"C:\Program Files\MyGame"))
{
...
}
The
@
mark is there to help to omit the escaping characters.
You could also check classes like
File
and
Path
, because they contain all sorts of helpful methods. Just type
File and a dot to see the methods.
There is also an alternative for C# program, an Inno setup script. I don't know if that's suitable for your case, but you could take a look at it.
http://www.jrsoftware.org/isinfo.php/[
^]
Edit:
You can save a resource with this method:
public static void SaveResource(string resourceName, string fileName)
{
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
{
byte[] b = new byte[stream.Length + 1];
stream.Read(b, 0, Convert.ToInt32(stream.Length));
fileStream.Write(b, 0, Convert.ToInt32(b.Length - 1));
fileStream.Flush();
fileStream.Close();
}
stream.Close();
}
Now you just call
SaveResource("ConsoleApplication.filename.dll", @"C:\filename.dll");
Note that the resource name is formatted as
namespace
dot
yourResourceName
.