Reputation: 259
I have to read all lines of a text file to perform some some changements on it . My problem is that I didn't find how to read the path file :
string Source = Dts.Variables["User::VarFilesToMove"].Value.ToString();
string folder = Dts.Variables["$Project::FichierBanque"].Value.ToString() ;
string folderFtp = Dts.Variables["$Project::FtpFolderInLocation"].Value.ToString();
string file = folder + Source + ".txt";
string[] lines = File.ReadAllLines(@"file");
//or string[] lines = File.ReadAllLines("file");
//string[] lines = File.ReadAllLines(file);
Many thanks for any help .
Upvotes: 0
Views: 119
Reputation: 3781
First to ensure that file exist. Try this
if (File.Exists(file))
{
string[] lines = File.ReadAllLines(file);
}
Upvotes: 2
Reputation: 46008
file
is a string
variable, just pass it to the method as parameter:
string[] lines = File.ReadAllLines(file);
Upvotes: 3