• 0

[VB.NET] Simple Program to Copy a file to a remote location


Question

Good Evening!

So, just at home, thinking about work and we have a common problem that requires a certain file to be copied over to a remote computer. So I'm making a really basic program to simplify the task for us.

The idea of it is, we keep the file on the root of C: and it copies it to a remote computer to a specific directory. After doing a little research, here is the simple code I ended up with.

Dim strCompName As String = ""

        strCompName = TextBox1.Text

        My.Computer.FileSystem.CopyFile("C:\file.dll", "\\" & strCompName & "\C$\Program Files\otherlocation")



    End Sub
End Class


Simple right? Well I must be using the wrong call. To test it, because I don't have a domain computer at home, it fails out with an I/O error stating the following:

could not complete operation since a directory already exists in this path

On the domain at work, we have full rights to the machine that is if everything is going right, so impersonation or authentication isn't an issue as far as that goes, but I've never done anything like this in vb so don't know if it is required. Any ideas?

6 answers to this question

Recommended Posts

  • 0
  On 31/05/2010 at 16:26, MrBalladeer said:

Good Idea!

Is there a switch that even if it exists, to overwrite the file? I'm getting an IO Exception: "File already exists"

If I could get it to just overwrite it, I think I would be in business!

My.Computer.FileSystem.CopyFile("C:\file.dll", "\\" & strCompName & "\C$\Program Files\otherlocation\file.dll", True)

^ voila... that simple for overwrite. (Assuming you have write privs)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Another win for EU users? Ads in WhatsApp won't be coming this year by David Uzondu You might have heard that ads are making their way to WhatsApp after years of the company promising it would never happen. If you are in the EU (lucky you), you won't be seeing ads until 2026 at the earliest. A new report from POLITICO confirms that Meta, which owns the messaging service, has informed Ireland's privacy regulator that the new advertising model will not roll out in the European Union for quite some time, even as it appears elsewhere in the coming months. This is not some charitable act, of course. The delay gives European regulators time to scrutinize the plan, which involves using ad preferences from linked Facebook and Instagram accounts to target users. This situation follows a pattern of other "wins" for EU users, like the changes in iOS 17.4 that finally enabled sideloading. This opened the door for alternative app stores and the (temporary) return of games like Fortnite to iPhones in the region. Similarly, we are seeing Microsoft finally back off from shoving Edge down the throats of EU users, all thanks to the Digital Markets Act. This legislation has put pressure on big tech companies to operate more "fairly" within the bloc, leading to changes that users everywhere else can only dream of for now. These regulations are precisely what companies like Apple hate. Remember, Apple has issued a warning to Australia, telling the country not to follow Europe's lead on these matters because it would create massive security and privacy risks. Apple argues that its control over the ecosystem keeps users safe, so any attempt to break that open is dangerous. The Irish Data Protection Commission will be meeting with WhatsApp to discuss the matter further. According to Commissioner Des Hogan, they plan to discuss the ad model with other European data protection authorities to gather any collective concerns. Commissioner Dale Sunderland noted that discussions with the company are "still early days", and it is too soon to identify what, if any, specific "red line issues" might exist with Meta's advertising plans. For now, Europeans can continue using their ad-free messenger, while the rest of the world prepares for the inevitable.
    • Welcome to Neowin!
    • Idiots never imagine their insane actions troubling everyone.  
    • Photo Variants 2.3 by Razvan Serea Photo Variants is an all-in-one photo editor for Windows. Quickly cull, import, and edit your images with powerful tools. Enjoy full layer support, precise retouching features, and a wide range of filters and color adjustments. Create multiple versions of a photo instantly with presets, or design from scratch using vector graphics and advanced editing options. Free for personal and commercial use. Photo Variants key Features: Advanced Adjustment Tools: Provides precise control over image modifications. ​ Extensive Filter Collection: Offers over 99 photo filters to apply various effects. ​ Animated Photo Effects: Enables the addition of dynamic elements to images. ​ Automatic Face Retouching: Includes features for enhancing facial features automatically. ​ Support for Multiple Formats: Compatible with over 100 graphic formats, including RAW and PSD files, allowing users to open, edit, and save in these formats. ​ Drawing and Transformation Tools: Facilitates freehand drawing, erasing, filling, cropping, resizing, rotating, and flipping images. Photo Variants supports a wide array of image formats, making it a versatile tool for all your editing needs. Key supported formats include: Raster Formats: .jpeg, .jpg, .png, .bmp, .gif, .tiff, .webp, .ico, .pcx. Camera RAW: .crw, .cr2, .dng, .nef, .raf, .arw, .orf, .x3f, .raw. Professional Formats: .psd, .ai, .svg, .tga, .pdf, .pcl. Specialized Formats: .dicom, .dcm, .heic, .heif, .avif, .exr, .dds. Other: .wmf, .emf, .xps, .jpeg2000 (.jp2)...etc... With support for these formats, Photo Variants offers seamless editing and flexibility for photographers, designers, and creatives. Photo Variants 2.3 changes: New effects for layers. New shapes and options for brushes. Download: Photo Variants 2.3 | 70.5 MB (Freeware) View: Photo Variants Home page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Internal PSU for these applications is bueno. External would be prone to noise and that is exactly something you do not want.
  • Recent Achievements

    • Week One Done
      Wayne Robinson earned a badge
      Week One Done
    • One Month Later
      Karan Khanna earned a badge
      One Month Later
    • Week One Done
      Karan Khanna earned a badge
      Week One Done
    • First Post
      MikeK13 earned a badge
      First Post
    • Week One Done
      OHI Accounting earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      692
    2. 2
      ATLien_0
      269
    3. 3
      Michael Scrip
      204
    4. 4
      +FloatingFatMan
      170
    5. 5
      Steven P.
      144
  • Tell a friend

    Love Neowin? Tell a friend!