Create new drive in a System using C#

K

Kondapanaidu

Hi,

I am using .NET 1.1 along with 2K Professional Operating System.

How to create a new drive in a system which is not available in my
system.

Example: My System is having the A,B,C,D,E these drives..

I need to create another drive like F which is not available.

I have the code for this...

Any body give the smart Idea rather than this One..

This is my code..

string [] ArrPossibleDrives=new
string[]{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"
,"Q","R","S","T","U","V","W","X","Y","Z"};

string [] ArrSysDrives=new string[10];
string strArrayElement;
string MapDrive="";
int a;
ArrSysDrives=System.IO.Directory.GetLogicalDrives();
for(int i=0;i<ArrSysDrives.Length;i++)
{
strArrayElement=ArrSysDrives;
strArrayElement=strArrayElement.Substring(0,strArrayElement.IndexOf(":",
0));
ArrSysDrives=strArrayElement.ToUpper();
}

for (int i=0; i<ArrSysDrives.Length; i++)
{
for (int j = 0; j < ArrPossibleDrives.Length; j++)
{
a = ArrSysDrives.CompareTo(ArrPossibleDrives[j]);
if(a==0) // If Exists=0 else returns -1
{
ArrPossibleDrives[j]=null;
}
}
}
for(int i=0;i<ArrPossibleDrives.Length;i++)
{
if(ArrPossibleDrives!=null)
{
MapDrive=ArrPossibleDrives;
break;
}
}

Thanks in advance for giving the great inputs

Thanks & regards
 
D

Daniel O'Connell [C# MVP]

Kondapanaidu said:
Hi,

I am using .NET 1.1 along with 2K Professional Operating System.

How to create a new drive in a system which is not available in my
system.

What do you mean by creating a new drive? Do you want to create a partition?
Map a drive letter to a volume? Map a network share? Or do you just want to
figure out what the next free drive is(which is sorta what your code sample
looks like it's doing?)

You can't just create drives like directories and there is no support in the
framework to do anything remotely like any of the possiblities(unless you
are just trying to figure out the next free drive), but if you can tell me
what you mean exactly I might be able to find out if it can be done
natively.
Example: My System is having the A,B,C,D,E these drives..

I need to create another drive like F which is not available.

I have the code for this...

Any body give the smart Idea rather than this One..

This is my code..

string [] ArrPossibleDrives=new
string[]{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"
,"Q","R","S","T","U","V","W","X","Y","Z"};

string [] ArrSysDrives=new string[10];
string strArrayElement;
string MapDrive="";
int a;
ArrSysDrives=System.IO.Directory.GetLogicalDrives();
for(int i=0;i<ArrSysDrives.Length;i++)
{
strArrayElement=ArrSysDrives;
strArrayElement=strArrayElement.Substring(0,strArrayElement.IndexOf(":",
0));
ArrSysDrives=strArrayElement.ToUpper();
}

for (int i=0; i<ArrSysDrives.Length; i++)
{
for (int j = 0; j < ArrPossibleDrives.Length; j++)
{
a = ArrSysDrives.CompareTo(ArrPossibleDrives[j]);
if(a==0) // If Exists=0 else returns -1
{
ArrPossibleDrives[j]=null;
}
}
}
for(int i=0;i<ArrPossibleDrives.Length;i++)
{
if(ArrPossibleDrives!=null)
{
MapDrive=ArrPossibleDrives;
break;
}
}

Thanks in advance for giving the great inputs

Thanks & regards
 
K

Kondapanaidu

Hi,

I am mapping drive with another system.i.e(My server) There some files
is there I need to fetch those files into my system.

For that I am mapping with that system.
I need One letter to map. Which is not available in my system.

Example: My system is having A,B,C,D,E

I need 'F' volume to Map that drive..

Thanks & regards
 
I

Ignacio Machin \( .NET/ C# MVP \)

HI,
I am mapping drive with another system.i.e(My server) There some files
is there I need to fetch those files into my system.

For that I am mapping with that system.
I need One letter to map. Which is not available in my system.

You can execute net like : "net use f: \\servername " , you can use the
Process class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top