私は教育ドメインのウェブサイトを開発しています。SQL Server 2008を使用してドキュメント (MS Word またはテキスト ファイル) をデータベースにバイナリ形式で保存したいのですFilestream
が、テキスト ボックスでドキュメントを取得できません。
私のコードは次のとおりです。
string path = reader.GetString(0);
SqlFileStream stream1 = new SqlFileStream(path, (byte[])reader.GetValue(1), FileAccess.Read, FileOptions.SequentialScan, 0);
StreamReader fs = new StreamReader(stream1);
fs = File.OpenText(path);
string s = fs.ReadToEnd();
txtInput.Text = s;
//lblStatus.Text = "File Succesfully Read!"
fs.Close();
このコードは、データベースではなくファイルシステムに保存されているドキュメントに対してのみ機能します。そこで、次のコードを試しました。
string path = reader.GetString(0);
SqlFileStream stream1 = new SqlFileStream(path, (byte[])reader.GetValue(1), FileAccess.Read, FileOptions.SequentialScan, 0);
StreamReader fs = new StreamReader(stream1);
fs = File.OpenText(path);
string s = fs.ReadToEnd();
txtInput.Text = s;
//lblStatus.Text = "File Succesfully Read!"
fs.Close();
このコードでは、fs = File.OpenText(path);
「パスへのアクセスが拒否されました」というエラーがオンラインで発生します。
助けてください!