我想用SourceFileName編寫FileStream,但是當我創建代碼時,錯誤消息指示正在使用文件流。如何替換,所以我打開源文件,然後寫下來,然後存儲在相同的源文件。由於如何在同一文件源中編寫文件流
SourceFileName =輸出
下面是代碼:
public void Encrypt(string SourceFileName, string output, string Key)
{
try
{
FileStream FS1 = null; FileStream FS2 = null;
FS1 = new FileStream(SourceFileName, FileMode.Open);
FS2 = new FileStream(output, FileMode.OpenOrCreate);
byte[] input = new byte[FS1.Length];
FS1.Read(input, 0, input.Length);
byte[] Encrypted = Encrypt(input, Key);
FS2.Write(Encrypted, 0, Encrypted.Length);
FS2.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
幫助時,您必須指定共享選項,但我需要替代碼你的意思。你可以嗎? – sloqye
當然可以,但那不是重點。你可以嗎?我已經告訴過你該怎麼做。現在輪到你至少嘗試去做了。如果你不嘗試,你不知道你做不到。 – jmcilhinney
謝謝。編號1.你可以在我的代碼中顯示一些代碼來實現它嗎? – sloqye