473,320 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Could someone help with this one?

JLW
I cannot get this to work correctly:

File.Create("\\.\PHYSICALDRIVE0")
or
File.Create("\\.\Tape0")
I've been searching for the better part of a week for this one.

Thanks,
JLW
Nov 20 '05 #1
12 1283
are you getting an error message when you try to create the file on the
drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
I cannot get this to work correctly:

File.Create("\\.\PHYSICALDRIVE0")
or
File.Create("\\.\Tape0")
I've been searching for the better part of a week for this one.

Thanks,
JLW

Nov 20 '05 #2
JLW
Actually, I'm trying to open the drive itself. I know it sounds crazy, but
I'm concentrating on the \\.\TAPE0 one first, so I can make a backup program
that won't cost me a few thousand bucks. The first one will return me a
handle, but for the TAPE0, I get no handle. I switched to using File.Open
and that seems to help a bit. I want to be able top open the harddrive at a
low level so that I can also make myself a low-level formatter (Zero-Fill
drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
are you getting an error message when you try to create the file on the
drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
I cannot get this to work correctly:

File.Create("\\.\PHYSICALDRIVE0")
or
File.Create("\\.\Tape0")
I've been searching for the better part of a week for this one.

Thanks,
JLW


Nov 20 '05 #3
Hi, JLW

you might need to use Win32 API CreateFile - see full description in
Platform SDK help or on MSDN.
I think .Net has some limitations, which files could be opened through
standard framework methods.

HTH
Alex

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy, but I'm concentrating on the \\.\TAPE0 one first, so I can make a backup program that won't cost me a few thousand bucks. The first one will return me a
handle, but for the TAPE0, I get no handle. I switched to using File.Open
and that seems to help a bit. I want to be able top open the harddrive at a low level so that I can also make myself a low-level formatter (Zero-Fill
drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
are you getting an error message when you try to create the file on the
drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
I cannot get this to work correctly:

File.Create("\\.\PHYSICALDRIVE0")
or
File.Create("\\.\Tape0")
I've been searching for the better part of a week for this one.

Thanks,
JLW



Nov 20 '05 #4
JLW
With that, the handle comes back as -1 every time, regardless of what I
specify as the "file". I have seen this work under VB6, which is why it's
soo damned frustraiting that it can't be done under the framework.

Thanks,
JLW
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi, JLW

you might need to use Win32 API CreateFile - see full description in
Platform SDK help or on MSDN.
I think .Net has some limitations, which files could be opened through
standard framework methods.

HTH
Alex

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy, but
I'm concentrating on the \\.\TAPE0 one first, so I can make a backup

program
that won't cost me a few thousand bucks. The first one will return me a
handle, but for the TAPE0, I get no handle. I switched to using File.Open and that seems to help a bit. I want to be able top open the harddrive at a
low level so that I can also make myself a low-level formatter

(Zero-Fill drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
are you getting an error message when you try to create the file on the drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
> I cannot get this to work correctly:
>
> File.Create("\\.\PHYSICALDRIVE0")
> or
> File.Create("\\.\Tape0")
>
>
> I've been searching for the better part of a week for this one.
>
> Thanks,
> JLW
>
>



Nov 20 '05 #5
JLW
Actually, I'm trying to open the drive itself. I know it sounds crazy, but
I'm concentrating on the \\.\TAPE0 one first, so I can make a backup program
that won't cost me a few thousand bucks. The first one will return me a
handle, but for the TAPE0, I get no handle. I switched to using File.Open
and that seems to help a bit. I want to be able top open the harddrive at a
low level so that I can also make myself a low-level formatter (Zero-Fill
drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
are you getting an error message when you try to create the file on the
drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
I cannot get this to work correctly:

File.Create("\\.\PHYSICALDRIVE0")
or
File.Create("\\.\Tape0")
I've been searching for the better part of a week for this one.

Thanks,
JLW


Nov 20 '05 #6
Hi, JLW

you might need to use Win32 API CreateFile - see full description in
Platform SDK help or on MSDN.
I think .Net has some limitations, which files could be opened through
standard framework methods.

HTH
Alex

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy, but I'm concentrating on the \\.\TAPE0 one first, so I can make a backup program that won't cost me a few thousand bucks. The first one will return me a
handle, but for the TAPE0, I get no handle. I switched to using File.Open
and that seems to help a bit. I want to be able top open the harddrive at a low level so that I can also make myself a low-level formatter (Zero-Fill
drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
are you getting an error message when you try to create the file on the
drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
I cannot get this to work correctly:

File.Create("\\.\PHYSICALDRIVE0")
or
File.Create("\\.\Tape0")
I've been searching for the better part of a week for this one.

Thanks,
JLW



Nov 20 '05 #7
JLW,

how do you declare CreateFile?

Here is working sample - I tried it calling TF (@"\\.\PHYSICALDRIVE0") -
note @ before string and see function defnition below. I don't have tape -
ughhh!
Sample uses some prototypes from www.pinvoke.net - thank you guys!

public static int CREATE_NEW = 1;

public static int CREATE_ALWAYS = 2;

public static int OPEN_EXISTING = 3;

public static int OPEN_ALWAYS = 4;

public static int TRUNCATE_EXISTING = 5;
[DllImport("kernel32.dll", SetLastError=true)]

static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess,

uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition,

uint dwFlagsAndAttributes, IntPtr hTemplateFile);

[DllImport("kernel32.dll", SetLastError=true)]

static extern bool CloseHandle(IntPtr hObject);

private static void TF(string filename) {

IntPtr ptr = CreateFile(filename,0, 0,IntPtr.Zero, (uint)OPEN_EXISTING,0,
IntPtr.Zero);

/* Is bad handle? INVALID_HANDLE_VALUE */

if (ptr.ToInt32() == -1)

{

/* ask the framework to marshall the win32 error code to an exception */

Console.WriteLine(String.Format("{0}",Marshal.GetL astWin32Error()));

}

else

{

Console.WriteLine("Opened");

CloseHandle(ptr);

}

}

HTH
Alex

"JLW" <as***@someplace.com> wrote in message
news:u9**************@TK2MSFTNGP10.phx.gbl...
With that, the handle comes back as -1 every time, regardless of what I
specify as the "file". I have seen this work under VB6, which is why it's
soo damned frustraiting that it can't be done under the framework.

Thanks,
JLW
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi, JLW

you might need to use Win32 API CreateFile - see full description in
Platform SDK help or on MSDN.
I think .Net has some limitations, which files could be opened through
standard framework methods.

HTH
Alex

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy,
but
I'm concentrating on the \\.\TAPE0 one first, so I can make a backup program
that won't cost me a few thousand bucks. The first one will return me
a handle, but for the TAPE0, I get no handle. I switched to using

File.Open and that seems to help a bit. I want to be able top open the
harddrive at
a
low level so that I can also make myself a low-level formatter

(Zero-Fill drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> are you getting an error message when you try to create the file on the > drive>?
> "JLW" <as***@someplace.com> wrote in message
> news:uG*************@tk2msftngp13.phx.gbl...
> > I cannot get this to work correctly:
> >
> > File.Create("\\.\PHYSICALDRIVE0")
> > or
> > File.Create("\\.\Tape0")
> >
> >
> > I've been searching for the better part of a week for this one.
> >
> > Thanks,
> > JLW
> >
> >
>
>



Nov 20 '05 #8
JLW
With that, the handle comes back as -1 every time, regardless of what I
specify as the "file". I have seen this work under VB6, which is why it's
soo damned frustraiting that it can't be done under the framework.

Thanks,
JLW
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi, JLW

you might need to use Win32 API CreateFile - see full description in
Platform SDK help or on MSDN.
I think .Net has some limitations, which files could be opened through
standard framework methods.

HTH
Alex

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy, but
I'm concentrating on the \\.\TAPE0 one first, so I can make a backup

program
that won't cost me a few thousand bucks. The first one will return me a
handle, but for the TAPE0, I get no handle. I switched to using File.Open and that seems to help a bit. I want to be able top open the harddrive at a
low level so that I can also make myself a low-level formatter

(Zero-Fill drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
are you getting an error message when you try to create the file on the drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
> I cannot get this to work correctly:
>
> File.Create("\\.\PHYSICALDRIVE0")
> or
> File.Create("\\.\Tape0")
>
>
> I've been searching for the better part of a week for this one.
>
> Thanks,
> JLW
>
>



Nov 20 '05 #9
JLW,

how do you declare CreateFile?

Here is working sample - I tried it calling TF (@"\\.\PHYSICALDRIVE0") -
note @ before string and see function defnition below. I don't have tape -
ughhh!
Sample uses some prototypes from www.pinvoke.net - thank you guys!

public static int CREATE_NEW = 1;

public static int CREATE_ALWAYS = 2;

public static int OPEN_EXISTING = 3;

public static int OPEN_ALWAYS = 4;

public static int TRUNCATE_EXISTING = 5;
[DllImport("kernel32.dll", SetLastError=true)]

static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess,

uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition,

uint dwFlagsAndAttributes, IntPtr hTemplateFile);

[DllImport("kernel32.dll", SetLastError=true)]

static extern bool CloseHandle(IntPtr hObject);

private static void TF(string filename) {

IntPtr ptr = CreateFile(filename,0, 0,IntPtr.Zero, (uint)OPEN_EXISTING,0,
IntPtr.Zero);

/* Is bad handle? INVALID_HANDLE_VALUE */

if (ptr.ToInt32() == -1)

{

/* ask the framework to marshall the win32 error code to an exception */

Console.WriteLine(String.Format("{0}",Marshal.GetL astWin32Error()));

}

else

{

Console.WriteLine("Opened");

CloseHandle(ptr);

}

}

HTH
Alex

"JLW" <as***@someplace.com> wrote in message
news:u9**************@TK2MSFTNGP10.phx.gbl...
With that, the handle comes back as -1 every time, regardless of what I
specify as the "file". I have seen this work under VB6, which is why it's
soo damned frustraiting that it can't be done under the framework.

Thanks,
JLW
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi, JLW

you might need to use Win32 API CreateFile - see full description in
Platform SDK help or on MSDN.
I think .Net has some limitations, which files could be opened through
standard framework methods.

HTH
Alex

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy,
but
I'm concentrating on the \\.\TAPE0 one first, so I can make a backup program
that won't cost me a few thousand bucks. The first one will return me
a handle, but for the TAPE0, I get no handle. I switched to using

File.Open and that seems to help a bit. I want to be able top open the
harddrive at
a
low level so that I can also make myself a low-level formatter

(Zero-Fill drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> are you getting an error message when you try to create the file on the > drive>?
> "JLW" <as***@someplace.com> wrote in message
> news:uG*************@tk2msftngp13.phx.gbl...
> > I cannot get this to work correctly:
> >
> > File.Create("\\.\PHYSICALDRIVE0")
> > or
> > File.Create("\\.\Tape0")
> >
> >
> > I've been searching for the better part of a week for this one.
> >
> > Thanks,
> > JLW
> >
> >
>
>



Nov 20 '05 #10
Though I'll probably never use this, did want to ask a question about the
tape drive and how it works with windows.

By using the UNC path to the tape drive does windows automatically take care
of all the IO functions(i.e. rewinding the tape, forwarding the tape to the
proper position). My knowledge on how tape drives actually work with the
system is rather limited, just wanted to know if that functionality was
already built into windows or not

Thanks,
CJ

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy, but I'm concentrating on the \\.\TAPE0 one first, so I can make a backup program that won't cost me a few thousand bucks. The first one will return me a
handle, but for the TAPE0, I get no handle. I switched to using File.Open
and that seems to help a bit. I want to be able top open the harddrive at a low level so that I can also make myself a low-level formatter (Zero-Fill
drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
are you getting an error message when you try to create the file on the
drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
I cannot get this to work correctly:

File.Create("\\.\PHYSICALDRIVE0")
or
File.Create("\\.\Tape0")
I've been searching for the better part of a week for this one.

Thanks,
JLW



Nov 20 '05 #11
JLW
Supposidly it is, but there's very little documentation on it, and the
Platform SDK really sucks on the subject.
I'm going to give another shot at it later today and will post back what
I've been able to figure out to date.

JLW
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Though I'll probably never use this, did want to ask a question about the
tape drive and how it works with windows.

By using the UNC path to the tape drive does windows automatically take care of all the IO functions(i.e. rewinding the tape, forwarding the tape to the proper position). My knowledge on how tape drives actually work with the
system is rather limited, just wanted to know if that functionality was
already built into windows or not

Thanks,
CJ

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy, but
I'm concentrating on the \\.\TAPE0 one first, so I can make a backup

program
that won't cost me a few thousand bucks. The first one will return me a
handle, but for the TAPE0, I get no handle. I switched to using File.Open and that seems to help a bit. I want to be able top open the harddrive at a
low level so that I can also make myself a low-level formatter

(Zero-Fill drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
are you getting an error message when you try to create the file on the drive>?
"JLW" <as***@someplace.com> wrote in message
news:uG*************@tk2msftngp13.phx.gbl...
> I cannot get this to work correctly:
>
> File.Create("\\.\PHYSICALDRIVE0")
> or
> File.Create("\\.\Tape0")
>
>
> I've been searching for the better part of a week for this one.
>
> Thanks,
> JLW
>
>



Nov 20 '05 #12
Hey JLW,

Thanks for responding. Look forward to reading your findings.

-CJ

"JLW" <as***@someplace.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl...
Supposidly it is, but there's very little documentation on it, and the
Platform SDK really sucks on the subject.
I'm going to give another shot at it later today and will post back what
I've been able to figure out to date.

JLW
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Though I'll probably never use this, did want to ask a question about the
tape drive and how it works with windows.

By using the UNC path to the tape drive does windows automatically take care
of all the IO functions(i.e. rewinding the tape, forwarding the tape to

the
proper position). My knowledge on how tape drives actually work with the system is rather limited, just wanted to know if that functionality was
already built into windows or not

Thanks,
CJ

"JLW" <as***@someplace.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Actually, I'm trying to open the drive itself. I know it sounds crazy,
but
I'm concentrating on the \\.\TAPE0 one first, so I can make a backup

program
that won't cost me a few thousand bucks. The first one will return me

a handle, but for the TAPE0, I get no handle. I switched to using

File.Open and that seems to help a bit. I want to be able top open the
harddrive at
a
low level so that I can also make myself a low-level formatter

(Zero-Fill drive).

Thanks,
JLW
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> are you getting an error message when you try to create the file on the > drive>?
> "JLW" <as***@someplace.com> wrote in message
> news:uG*************@tk2msftngp13.phx.gbl...
> > I cannot get this to work correctly:
> >
> > File.Create("\\.\PHYSICALDRIVE0")
> > or
> > File.Create("\\.\Tape0")
> >
> >
> > I've been searching for the better part of a week for this one.
> >
> > Thanks,
> > JLW
> >
> >
>
>



Nov 20 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MarcJessome | last post by:
Hi, I was wondering if someone could help me through learning C++. I've tried learning before, but I find I would work better if I had someone that could help explain a few things to me. Im using...
6
by: erebus- | last post by:
When learning the C programing languages, i have had and still am having the problem of not being able to find answers to many questions. Is their an overall guide/reference that someone knows?
2
by: Shimon Sim | last post by:
Hi I started using SharePoint services and noticed that it works great with Word - just open doc and edit. could it be done with ASP.NET by regular people? May be someone can give a hint in right...
1
by: joserobenator | last post by:
All right. I'v been the last 24h looking everywhere for a solution: -- Description: An error occurred during the processing of a configuration file required to service this request. Please...
3
by: Anthony Fine | last post by:
Hello All, I have a VB.Net app that needs to send mail. I have created a class for building my e-mail, but keep getting the error (Could not access 'CDO.Message' object.) when trying to send...
3
by: Amy | last post by:
Hi, I have 6 If Then Else statements I was supposed to write. I did so but I know that they have to be wrong because they all look the same. Could someone take a look at them and point me in the...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
0
by: Homer | last post by:
Hi, I got "InnerException: Unable to connect to remote server"..."No connection could be made because the target machine actively refused it" when I attempted to send an email through my...
1
by: mycomputertutor | last post by:
Hi Folks, I am a new member and was wondering if someone could help answer a problem that I am getting from a recently uploaded website from 1 server host to another. I am getting an error message...
11
by: fniles | last post by:
One of our application uses VB6 and Access97 database. Another application uses VB.NET 2005. This morning for about 15 seconds when the application tries to read either a query or a table from the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.