Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2004

Tip: Looking for answers? Try searching our database.

I wanna know how to copy to Network share folder(ex. \\servername\c$)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rookie - 30 Mar 2004 02:26 GMT
I wanna know how to copy file to network folder.
For example
        string sourceFile = @"c:\test.txt"
        string destFile = @"\\servername\sharefolder"
        FileInfo sourceFile = new FileInfo(sourceFilename)
        FileInfo destFile = new FileInfo(destFilename)
        sourceFile.CopyTo(destFilename, true)

In this case, I wanna how to process inputing ID & PWD in source code

thanks!
DotNetJunkies User - 19 Oct 2004 18:29 GMT
To copy a file to a network share folder, you must make a connection first. For making a connection simple use the following function. Note that you have to add a reference to 'system.management' first. Also, you should add the line 'Imports System.Management' to your code.

   Private Function ConnectToServer(ByVal Host As String, ByVal User As String, ByVal Password As String) As Boolean
       Dim Scope As Management.ManagementScope
       Dim Options As Management.ConnectionOptions
       Options = New ConnectionOptions
       Options.Username = Host & "\" & User
       Options.Password = Password
       Try
           Scope = New ManagementScope("\\" & Host & "\root\cimv2", Options)
           Scope.Connect()
           If Scope.IsConnected Then
               Return True
           Else
               Return False
           End If
       Catch ex As Exception
           Return False
       End Try
   End Function

---

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.