How to select a drive?  
Author Message
Barney98629





PostPosted: Thu Apr 15 09:15:46 CDT 2004 Top

Visual C#.Net >> How to select a drive?

How do you select a drive to write a file to?
In Visual Basic it is

ChDrive("D")

where D is the new drive letter. How do you do it in C#?

I could not find it in the msdn Library or at the Visual C# .NET Support
Center.

-Harry

DotNet337  
 
 
=?ISO-8859-2?Q?Marcin_Grz=EAbski?=





PostPosted: Thu Apr 15 09:15:46 CDT 2004 Top

Visual C#.Net >> How to select a drive? Hi Harry,

> How do you select a drive to write a file to?
> In Visual Basic it is
>
> ChDrive("D")
>
> where D is the new drive letter. How do you do it in C#?
>
> I could not find it in the msdn Library or at the Visual C# .NET Support
> Center.
>
> -Harry

Drive list you can get by:
Directory.GetLogicalDrives

Directory.GetCurrentDirectory & Directory.SetCurrentDirectory
can be used to keep your drive.

Why do you want drive to write files instead of any directory path?

Marcin
 
 
sleepyinsomniac





PostPosted: Thu Apr 15 09:43:31 CDT 2004 Top

Visual C#.Net >> How to select a drive? Include your drive letter in your read or write operations that accept a
path.

xmlDS.WriteXml(path + "XmlDataSource.xml", XmlWriteMode.WriteSchema);

where path could be "d:\\yourPath\\yourDirectory\\subDirectory\\"

Let me know if this is what your looking for. If not please include your
code.
Phil
http://www.telysium.org



> How do you select a drive to write a file to?
> In Visual Basic it is
>
> ChDrive("D")
>
> where D is the new drive letter. How do you do it in C#?
>
> I could not find it in the msdn Library or at the Visual C# .NET Support
> Center.
>
> -Harry
>
>


 
 
Harry





PostPosted: Thu Apr 15 15:54:05 CDT 2004 Top

Visual C#.Net >> How to select a drive?


> Hi Harry,
>
> > How do you select a drive to write a file to?
> > In Visual Basic it is
> >
> > ChDrive("D")
> >
> > where D is the new drive letter. How do you do it in C#?
> >
> > I could not find it in the msdn Library or at the Visual C# .NET Support
> > Center.
> >
> > -Harry
>
> Drive list you can get by:
> Directory.GetLogicalDrives
>
> Directory.GetCurrentDirectory & Directory.SetCurrentDirectory
> can be used to keep your drive.
>
> Why do you want drive to write files instead of any directory path?
>
> Marcin

I am converting one of my programs from Visual Basic to C#, and I guess you
don't need to change drives before you write to a file be file name only,
just set the current directory.

-Harry


 
 
Harry





PostPosted: Thu Apr 15 15:54:59 CDT 2004 Top

Visual C#.Net >> How to select a drive? I am converting one of my programs from Visual Basic to C#, and I guess you
don't need to change drives before you write to a file be file name only,
just set the current directory.

-Harry



> Include your drive letter in your read or write operations that accept a
> path.
>
> xmlDS.WriteXml(path + "XmlDataSource.xml", XmlWriteMode.WriteSchema);
>
> where path could be "d:\\yourPath\\yourDirectory\\subDirectory\\"
>
> Let me know if this is what your looking for. If not please include your
> code.
> Phil
> http://www.telysium.org


>
> > How do you select a drive to write a file to?
> > In Visual Basic it is
> >
> > ChDrive("D")
> >
> > where D is the new drive letter. How do you do it in C#?
> >
> > I could not find it in the msdn Library or at the Visual C# .NET Support
> > Center.
> >
> > -Harry
> >
> >
>
>


 
 
Michael





PostPosted: Fri Apr 16 16:35:02 CDT 2004 Top

Visual C#.Net >> How to select a drive? > > How do you select a drive to write a file to?
> > In Visual Basic it is
> >
> > ChDrive("D")
> >
> > where D is the new drive letter. How do you do it in C#?
> >
> > I could not find it in the msdn Library or at the Visual C# .NET Support
> > Center.

In case anyone wonders how the question came up, this is actually an echo of
DOS 1.0 and 1.1. Before DOS 2.0 (1983), there were no subdirectories and
instead of selecting a current directory, all you could do was select drive
A or B (first or second diskette). (No hard disks in those days either.)

Nowadays you can still select current disk, and there is (at all times) a
current directory selected on each disk. So your complete current directory
at any given time = the current disk + the selected directory on that disk.

Nowadays some files are on a network path (such as \\blah\blither) and not a
drive letter at all.