嗨,我正在使用,
FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read);
从我在调试目录中定义但没有成功的临时文件夹中读取文件。使用此代码,我可以仅从 Debug-Folder 读取文件。谁能帮忙!
这是我的代码
private void button_click(object sender, RoutedEventArgs e)
{
string activeDirectory = System.Windows.Forms.Application.StartupPath + "\\Temp\\";
string[] files = Directory.GetFiles(activeDirectory);
try
{
foreach (string fileName in files.Select(f => f.Substring(activeDirectory.Length)))
{
FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read);
}
}
catch()
{}
}