reuse instance - can't get format correct
Posted on 2006-07-20
This is likely a silly question but I can't seem to figure out the format....
I am creating a FileInfo instance that I want to reuse in a loop...changing the file that I'm looking for information on. I did not want to create a new instance for every file. This is what I have so far.....I don't have my loop created but don't worry about that.... I'll get to that... the problem is the line: file = FileInfo(strBakFileName); Basically, I'm trying to reuse instance of file and set it to a new file name and then do a file.Exists on the new file name. I've tried file = (FileInfo)strBakFileName and that does work....
FileInfo file = new FileInfo(strCommissionsPath);
string strBakFileName = strCommissionsPath;
strBakFileName = strBakFileName.Insert(strBakFileName.IndexOf(".csv"), intCounter.ToString());
strBakFileName = strBakFileName.Replace(".csv", ".bak");
file = FileInfo(strBakFileName);
intCounter = intCounter + 1;
Thanks so much for your help!