Currently I have as my file path
@"S:\Temporary Shared Space\Project\Boyscout3\Data\full_pack.txt"
I want it to be just "full_pack.txt".
I tried this code on the bottom but it appears to not be working for me:
If someone could please help I would appreciate it.
string fileName =@"S:\Temporary Shared Space\Project\Boyscout\Data\full_pack.txt";
string path = "full_pack.txt";
string result;
result = System.IO.Path.GetFileName(fileName);
Console.WriteLine("GetFileName('{0}') returns '{1}'", fileName, result);
result = System.IO.Path.GetFileName(path);
Console.WriteLine("GetFileName('{0}') returns '{1}'", path, result);
//filename shorter for den1
string fileName1 =@"S:\Temporary Shared Space\Project\Boyscout3\Data\den1.txt";
string path1 = "den1.txt";
string result1;
result1 = System.IO.Path.GetFileName(fileName1);
Console.WriteLine("GetFileName('{0}') returns '{1}'", fileName1, result1);
result1 = System.IO.Path.GetFileName(path1);
Console.WriteLine("GetFileName('{0}') returns '{1}'", path1, result1);
//Making a list for full_pack
List<string> listFullPack = new List<string>();
string line;
StreamReader sr = new StreamReader("full_pack.txt");//this is where things don't work.
while ((line = sr.ReadLine()) != null)////When the full address is in, the code works,
{ //but when I replace it with full_pack.txt,
listFullPack.Add(line); //it can't find the file.
}
sr.Close();