[英]How to open excel file's read only mode on C#?
I'm creating dataset from csv excel file and that files is processing while I access it. 我正在从csv excel文件创建数据集,并且在访问文件时正在处理这些文件。
It says " 它说 ”
I need to access it read only mode? 我需要访问它的只读模式吗? This is working code. 这是工作代码。
private void connect()
{
try
{
if (checkbox1.Checked == false)
{
FilePath = @"C:\FILE";
}
else
{
FilePath = @"\\192.168.0.2\file\"; //
}
strConn = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + FilePath + @"\;Extensions=csv,txt";
Connect = new OdbcConnection(strConn);
Connect.Open();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
DataGrid1.SelectAll();
DataGrid1.ClearSelection();
FileName = ".csv";
CSVDataSource = FilePath + FileName;
ReadData(FileName);
DataGrid1.Update();
}
It says it cannot open the file '(unknown)'. 它说无法打开文件“(未知)”。 The thing about exclusive and permissions is probably just a too general error description. 关于独占和权限的问题可能只是一个过于笼统的错误描述。 You do not seem to have a valid file path, also you might not be able to open it directly from a network path. 您似乎没有有效的文件路径,也可能无法直接从网络路径打开它。 Verify your file path, and if it still not works - copy it to your local machine and try again. 验证您的文件路径,如果仍然无法使用-将其复制到本地计算机,然后重试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.