PDA

View Full Version : نوشتن روی دیسک



zahra faraji
دوشنبه 19 دی 1390, 15:00 عصر
سلام دوستان
مشکلم رو برای خوندن سکتور خاص از دیسک حل کردم.:چشمک:
ولی برای نوشتن روی سکتور خاص مشکل دارم. کد من به صورت زیره:

FileStream fs;
SafeFileHandle handle
int blockSize = 512;

/* Call the Windows CreateFile() API to open the file.
* The number of wanted Removable disk in management part of My Computer is "1".
*/
handle = CreateFile("\\\\.\\PHYSICALDRIVE1", (int)FileAccess.ReadWrite, FileShare.ReadWrite, IntPtr.Zero,
FileMode.Open, 0, IntPtr.Zero);
MessageBox.Show("handle is made...");
fs = new FileStream(handle, FileAccess.ReadWrite, blockSize, false);
fs.Seek(512 * Int32.Parse(textBox1.Text), SeekOrigin.Begin);
fs.Write(b, 0, b.Length);

نممیدونم چرا بهم خطای access to the path is denied رو میده وقتی میخواد ارایه بایت رو بنویسه.

zahra faraji
چهارشنبه 21 دی 1390, 08:23 صبح
جالب ها یعنی هیچ کس بلد نیست؟