Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* list the files under the folder.*/
- string filePath = @"C:\folder\data.txt";
- if (File.Exists(filePath) == true)
- {
- DirectoryInfo direcPath = new DirectoryInfo(@"C:\folder\");
- FileInfo[] rgFiles = direcPath.GetFiles();
- foreach (FileInfo fi in rgFiles)
- {
- if(!(fi.Name == "data.txt"))
- {
- labelName.Add(fi.Name.Substring(0,(fi.Name.Length - 4)));
- }
- }
- }
- else
- {
- Directory.CreateDirectory(@"C:\folder");
- FileStream fs = File.Create(@"C:\folder\data.txt");
- fs.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement