C# 正在尝试读取文本文件
我必须读取文本文件的所有行,才能对其执行一些更改。 我的问题是,我没有找到如何读取路径文件:C# 正在尝试读取文本文件,c#,C#,我必须读取文本文件的所有行,才能对其执行一些更改。 我的问题是,我没有找到如何读取路径文件: string Source = Dts.Variables["User::VarFilesToMove"].Value.ToString(); string folder = Dts.Variables["$Project::FichierBanque"].Value.ToString() ; string folderFtp = Dts.Variables["$Project::FtpFolderIn
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);
非常感谢您的帮助。
文件
是一个字符串
变量,只需将其作为参数传递给方法即可:
string[]lines=File.ReadAllLines(文件)
文件
是一个字符串
变量,只需将其作为参数传递给方法即可:
string[]lines=File.ReadAllLines(文件)首先编码>以确保文件存在。试试这个
if (File.Exists(file))
{
string[] lines = File.ReadAllLines(file);
}
首先要确保文件存在。试试这个
if (File.Exists(file))
{
string[] lines = File.ReadAllLines(file);
}
你最后一条评论行有什么问题?你最后一条评论行有什么问题?