サーバーの My Documents フォルダーにある別のアプリケーションのログ ファイルを読み取る ASP.NET 4.5 アプリケーションを開発しています。デバッグモードで実行するとうまく機能しますが、一度展開することはありません。次のエラーが発生します。
「C:\Users\Performance\My Folder\Log\」は有効なパスではありません。パス名のつづりが正しいこと、およびファイルが存在するサーバーに接続していることを確認してください。
Network Service と IISUSER にこのファイルへの読み取り/書き込みアクセスを許可しました (フォルダーではなく、このファイルのみ) 。
この私のコード:
protected void lstArea_TextChanged(object sender, EventArgs e)
{
//create instance foe oledb connection class
OleDbConnection con = new OleDbConnection();
//Your datasource Location path currently i placed csv file in server location
string dsource = lstArea.SelectedValue;
//Put your datasource path in the connection string for example if you have csv files in C:\ directory change datasource= C:\
string constr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dsource + ";Extended Properties='text;HDR=No;FMT=Delimited';";
try
{
con.ConnectionString = constr;
//create instance for command object
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
// set your file name in the below query
cmd.CommandText = "select * from [wksplog.txt]";
//Open Oledb Connection to read CSV file
con.Open();
//Create one datatable to store data from CSV file
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader(), LoadOption.OverwriteChanges);
//Bind data in the Gridview
gvMain.DataSource = dt;
gvMain.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
}
ディレクトリを C:\Users\Performance\My Folder\Log\ として渡しています
何がうまくいかないのですか?ところで、匿名/フォーム認証を使用しています。このマシンはドメインにありません。