• 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

    • Charlie Manson, They must be his devotees.
    • Download Excel Quick and Easy (worth $12) for free by Steven Parker Claim your complimentary eBook worth $12 for free, before the offer ends on June 24. Drawn from the most important tasks in the latest bestselling Excel Bible , Excel Quick and Easy is your ticket to data mastery. Excel veterans Michael Alexander and Dick Kusleika distil the most essential and useful tasks you need to understand about the world's most popular spreadsheet program, from functions to charts, graphs, formulas and more. Prepare for a whirlwind tour of Excel, packed with simple and step-by-step guides to common and lesser-known Excel features. This book shows you how to: Create new spreadsheets and workbooks by entering and editing worksheet data Simplify working with large amounts of data by naming and moving ranges Make calculations and draw conclusions from your data by using formulas Visualize and present your data by creating functional charts The secret weapon in your productivity arsenal Being great at Excel is quickly becoming a standard expectation for a ton of employers and organizations, in all sorts of industries. Sharpening your skills can boost your workplace performance and make it easier to land promotions or find new roles. Excel Quick and Easy makes it a breeze to develop the proficiencies that help you stand out from your peers. Unique features of this book Step-by-step guides to the most commonly used and productive Excel tasks, from basic worksheet operations to formatting spreadsheets for hardcopy printing Intuitive explanations for making your data tell a compelling story with visualizations, including charts, graphs, and tables Advanced number-crunching techniques, including formulas and functions, that help you unlock fresh insights and new conclusions from your data Excel Quick and Easy is the perfect reference for brand-new Excel users trying to get up-to-speed quickly and confidently. It's also a must-read for anyone migrating from another spreadsheet program, like Google Sheets, or more experienced Excel users who need to solidify and improve their skills. If you're tired of stumbling through your spreadsheets and just “surviving” in Excel, grab a copy of Excel Quick and Easy and supercharge your productivity. You'll refine your understanding of the basics, learn brand-new skills and features, and become the Excel expert that every office desperately needs. This free to download offer expires June 24. How to get it Please ensure you read the terms and conditions to claim this offer. Complete and verifiable information is required in order to receive this free offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last! Download Excel Quick and Easy (worth $12) for free Offered by Packt, view other free resources The below offers are also available for free in exchange for your (work) email: AI and Innovation ($21 Value) FREE – Expires 6/11 Unruly: Fighting Back when Politics, AI, and Law Upend [...] ($18 Value) FREE - Expires 6/17 SQL Essentials For Dummies ($10 Value) FREE – Expires 6/17 Continuous Testing, Quality, Security, and Feedback ($27.99 Value) FREE – Expires 6/18 VideoProc Converter AI v7.5 for FREE (worth $78.90) – Expires 6/18 Macxvideo AI ($39.95 Value) Free for a Limited Time – Expires 6/22 Excel Quick and Easy ($12 Value) FREE – Expires 6/24 The Inclusion Equation: Leveraging Data & AI ($21 Value) FREE – Expires 6/24 Microsoft 365 Copilot At Work ($60 Value) FREE – Expires 6/25 Natural Language Processing with Python ($39.99 Value) FREE – Expires 6/25 How to Engage Buyers and Drive Growth in the Age of AI ($22.95 Value) FREE – Expires 7/1 Using Artificial Intelligence to Save the World ($30.00 Value) FREE – Expires 7/1 Essential: How Distributed Teams, Generative AI, [...] ($18.00 Value) FREE – Expires 7/2 The Chief AI Officer's Handbook: Master AI leadership with strategies to innovate, overcome challenges, and drive business growth ($9.99 Value) FREE for a Limited Time – Expires 7/2 The Ultimate Linux Newbie Guide – Featured Free content Python Notes for Professionals – Featured Free content Learn Linux in 5 Days – Featured Free content Quick Reference Guide for Cybersecurity – Featured Free content We post these because we earn commission on each lead so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin The above deal not doing it for you, but still want to help? Check out the links below. Check out our partner software in the Neowin Store Buy a T-shirt at Neowin's Threadsquad Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: An account at Neowin Deals is required to participate in any deals powered by our affiliate, StackCommerce. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through the branded deals site.
    • At least Starship Block 2 is consistent in failure.  They were lucky it was not the stack. That would have been really huge. 
    • VR is dead on the PS at this rate, sales just aren't there. Way more VR push on the PC, even Sony knows this and that's why they added PC support to the PSVR.
  • Recent Achievements

    • First Post
      MikeK13 earned a badge
      First Post
    • One Month Later
      OHI Accounting earned a badge
      One Month Later
    • Week One Done
      OHI Accounting earned a badge
      Week One Done
    • First Post
      Thornskade earned a badge
      First Post
    • Week One Done
      Higante88 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      716
    2. 2
      ATLien_0
      273
    3. 3
      Michael Scrip
      203
    4. 4
      +FloatingFatMan
      182
    5. 5
      Steven P.
      128
  • Tell a friend

    Love Neowin? Tell a friend!