473,387 Members | 1,664 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,387 software developers and data experts.

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 2734
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jonas | last post by:
Good day, I have a .bat script I'm invoking thru a cgi script (PERL) with (NT/IIS) on a internal network. The .bat script is having problems accessing network drives, it keeps saying "Invalid...
8
by: Leo R | last post by:
Hi, Is it possible to create a network-drive at the SYSTEM-level? E.g.: map X: to \\server1\share so a windows service can reach X: without having to log on? I want a Windows .NET service to...
7
by: Eric.Jones | last post by:
I've encountered a strange error with loading delimited files from a Samba (SMB) network drive, has anyone else seen this before? (Platform: WinXP Pro, UDB PE 8015, level 02060106, SAMPLE db) ...
7
by: ddsvi78 | last post by:
I am a complete idiot when it comes to access. Now that said, I work for a computer security company and one of our customers came to us with an access problem. They had been running fine for a...
5
by: Niloday | last post by:
Hi All, I am trying to access a mapped network drive from a service that I have created. The service needs to create/delete folders/files on a network drive. When I tried to connect to a...
5
by: Nirosh | last post by:
Hi All, Can any one suggest me a best way to do this .. I have a thrid party tool "EXE" that we need to use with our web service to manipulate some complex XML files, which reside in a...
4
by: Matt Dockerty | last post by:
Hi, I'm trying to connect to a network share using a username / password / domain of my choosing. I've tried the WindowsIdentity.Impersonate route but can only impersonate the users on the...
11
by: Andre | last post by:
Hi, I have ASP.NET application running on standalone (not part of the domain) Windows 2003. I use forms authentication for my application. The problem I have is that I need to create and read...
24
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
Hello, I'm trying to create an admin page that can run miscellaneous scripts for our IT department. Currently, I'm trying to create a script that can map a network drive for a user (e.g. a form...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.