Network Share Drives

  • Thread starter Thread starter Default User
  • Start date Start date
D

Default User

Hi
How can i look for network share folders and copy a text file to it? I've
been looking into how i can do this in the documention but with no luck. I
found a little on of the web but i dont understand it, it seems to import
mpr.dll and make the use of c++ calls. Can this be just done by c#?
If so how?

Jamie C
 
Jamie C,

Why not just use the static Copy method on the File class?

Hope this helps.
 
But how do i find the network share drives to start with?
The example i've been looking at imports a dll,
[DllImport("mpr.dll")]

public static extern int WNetOpenEnum(ResourceScope dwScope, ResourceType
dwType, ResourceUsage dwUsage, NETRESOURCE lpNetResource, out IntPtr
lphEnum);

like but i cant find any examples in straight c#



Nicholas Paldino said:
Jamie C,

Why not just use the static Copy method on the File class?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Default User said:
Hi
How can i look for network share folders and copy a text file to it? I've
been looking into how i can do this in the documention but with no luck.
I found a little on of the web but i dont understand it, it seems to
import mpr.dll and make the use of c++ calls. Can this be just done by
c#?
If so how?

Jamie C
 
Jamie,

This could be a huge task. Are you looking for all of the network
shares exposed on one machine, or in the whole network?

If you know the machine you want to look for the shares on, then I would
use the classes in the System.Management namespace to query for all
instances of Win32_Share where the Type is 0. You can use pass a
ManagementPath instance (with the server specified) to the constructor of
the ManagementClass object to indicate that you want the query performed on
that machine.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Default User said:
But how do i find the network share drives to start with?
The example i've been looking at imports a dll,
[DllImport("mpr.dll")]

public static extern int WNetOpenEnum(ResourceScope dwScope, ResourceType
dwType, ResourceUsage dwUsage, NETRESOURCE lpNetResource, out IntPtr
lphEnum);

like but i cant find any examples in straight c#



Nicholas Paldino said:
Jamie C,

Why not just use the static Copy method on the File class?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Default User said:
Hi
How can i look for network share folders and copy a text file to it?
I've been looking into how i can do this in the documention but with no
luck. I found a little on of the web but i dont understand it, it seems
to import mpr.dll and make the use of c++ calls. Can this be just done
by c#?
If so how?

Jamie C
 
i'd need it to search the whole network, as file servers are being added or
drives being mapped all the time, and i need to put a disclaimer on the root
of each one. After a while it takes its tole keep copying and pasting all
the time :(

Jamie


Nicholas Paldino said:
Jamie,

This could be a huge task. Are you looking for all of the network
shares exposed on one machine, or in the whole network?

If you know the machine you want to look for the shares on, then I
would use the classes in the System.Management namespace to query for all
instances of Win32_Share where the Type is 0. You can use pass a
ManagementPath instance (with the server specified) to the constructor of
the ManagementClass object to indicate that you want the query performed
on that machine.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Default User said:
But how do i find the network share drives to start with?
The example i've been looking at imports a dll,
[DllImport("mpr.dll")]

public static extern int WNetOpenEnum(ResourceScope dwScope, ResourceType
dwType, ResourceUsage dwUsage, NETRESOURCE lpNetResource, out IntPtr
lphEnum);

like but i cant find any examples in straight c#



Nicholas Paldino said:
Jamie C,

Why not just use the static Copy method on the File class?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi
How can i look for network share folders and copy a text file to it?
I've been looking into how i can do this in the documention but with no
luck. I found a little on of the web but i dont understand it, it seems
to import mpr.dll and make the use of c++ calls. Can this be just done
by c#?
If so how?

Jamie C
 
That means you need need access privileges for all these shares too! What
makes you think you will have these?

Willy.


Default User said:
i'd need it to search the whole network, as file servers are being added
or drives being mapped all the time, and i need to put a disclaimer on the
root of each one. After a while it takes its tole keep copying and pasting
all the time :(

Jamie


Nicholas Paldino said:
Jamie,

This could be a huge task. Are you looking for all of the network
shares exposed on one machine, or in the whole network?

If you know the machine you want to look for the shares on, then I
would use the classes in the System.Management namespace to query for all
instances of Win32_Share where the Type is 0. You can use pass a
ManagementPath instance (with the server specified) to the constructor of
the ManagementClass object to indicate that you want the query performed
on that machine.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Default User said:
But how do i find the network share drives to start with?
The example i've been looking at imports a dll,
[DllImport("mpr.dll")]

public static extern int WNetOpenEnum(ResourceScope dwScope,
ResourceType dwType, ResourceUsage dwUsage, NETRESOURCE lpNetResource,
out IntPtr lphEnum);

like but i cant find any examples in straight c#



in message Jamie C,

Why not just use the static Copy method on the File class?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi
How can i look for network share folders and copy a text file to it?
I've been looking into how i can do this in the documention but with
no luck. I found a little on of the web but i dont understand it, it
seems to import mpr.dll and make the use of c++ calls. Can this be
just done by c#?
If so how?

Jamie C
 
Like i said before i've been copying and pasting these files to the drives
manually, which takes far too long, so i must have the privileges to do it
manually would i not?

Willy Denoyette said:
That means you need need access privileges for all these shares too! What
makes you think you will have these?

Willy.


Default User said:
i'd need it to search the whole network, as file servers are being added
or drives being mapped all the time, and i need to put a disclaimer on
the root of each one. After a while it takes its tole keep copying and
pasting all the time :(

Jamie


Nicholas Paldino said:
Jamie,

This could be a huge task. Are you looking for all of the network
shares exposed on one machine, or in the whole network?

If you know the machine you want to look for the shares on, then I
would use the classes in the System.Management namespace to query for
all instances of Win32_Share where the Type is 0. You can use pass a
ManagementPath instance (with the server specified) to the constructor
of the ManagementClass object to indicate that you want the query
performed on that machine.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

But how do i find the network share drives to start with?
The example i've been looking at imports a dll,
[DllImport("mpr.dll")]

public static extern int WNetOpenEnum(ResourceScope dwScope,
ResourceType dwType, ResourceUsage dwUsage, NETRESOURCE lpNetResource,
out IntPtr lphEnum);

like but i cant find any examples in straight c#



"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message Jamie C,

Why not just use the static Copy method on the File class?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi
How can i look for network share folders and copy a text file to it?
I've been looking into how i can do this in the documention but with
no luck. I found a little on of the web but i dont understand it, it
seems to import mpr.dll and make the use of c++ calls. Can this be
just done by c#?
If so how?

Jamie C
 
Back
Top