I am sitting here since 2 hours to find a solution for my problem. I wanna check whether a file exist.
I have a ButtonCreate class and in this class I create a Directory newSFO, the name of the Directory being MUMO. Then I want to check whether the file newSFoZipName exist and if the file exists do not create it. But it is not working. Thanks in advance!
newSFoZipName = MySubFName + MytbRevision + "__C8" + MyLastCh + ".zip";
if (LastCh == "M")
{
Regex rgx = new Regex(@"M");
tbRFolder = rgx.Replace(LastCh, "Mumo");
newSFo = Path.Combine(newSubPath, tbRFolder);
Directory.CreateDirectory(newSFo);
newSFoZip = Path.Combine(newSFo, newSFoZipName);
// File.Create(newSFoZipName).Close();
//string path2 = newSFo + newSFoZip;
File.Create(newSFoZipName).Close();
if (Directory.Exists(newSFoZip))
{
if (!File.Exists(newSFoZipName))
{
MessageBox.Show("File exists");
}
}
You write
instead of