468,458 Members | 1,828 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

Network Share Drives

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

Nov 17 '05 #1
6 2503
Jamie C,

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

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
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

Nov 17 '05 #2
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]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OP**************@TK2MSFTNGP09.phx.gbl...
Jamie C,

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

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
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



Nov 17 '05 #3
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]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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]" <mv*@spam.guard.caspershouse.com> wrote
in message news:OP**************@TK2MSFTNGP09.phx.gbl...
Jamie C,

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

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
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


Nov 17 '05 #4
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uO**************@TK2MSFTNGP09.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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]" <mv*@spam.guard.caspershouse.com> wrote
in message news:OP**************@TK2MSFTNGP09.phx.gbl...
Jamie C,

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

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
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



Nov 17 '05 #5
That means you need need access privileges for all these shares too! What
makes you think you will have these?

Willy.
"Default User" <an*******@discussions.microsoft.com> wrote in message
news:uf*************@TK2MSFTNGP12.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:uO**************@TK2MSFTNGP09.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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]" <mv*@spam.guard.caspershouse.com> wrote
in message news:OP**************@TK2MSFTNGP09.phx.gbl...
Jamie C,

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

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
> 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


Nov 17 '05 #6
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 [MVP]" <wi*************@telenet.be> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
That means you need need access privileges for all these shares too! What
makes you think you will have these?

Willy.
"Default User" <an*******@discussions.microsoft.com> wrote in message
news:uf*************@TK2MSFTNGP12.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:uO**************@TK2MSFTNGP09.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Default User" <an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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]" <mv*@spam.guard.caspershouse.com>
wrote in message news:OP**************@TK2MSFTNGP09.phx.gbl...
> Jamie C,
>
> Why not just use the static Copy method on the File class?
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
> "Default User" <an*******@discussions.microsoft.com> wrote in message
> news:51**********************************@microsof t.com...
>> 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
>
>



Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Matt Dockerty | last post: by
24 posts views Thread by =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.