Click here to Skip to main content
13,199,852 members (66,498 online)
Rate this:
 
Please Sign up or sign in to vote.
Dim newName As String = String.Format("{0}.exe", Path.GetRandomFileName().Replace(".", ""))
        Dim oldName As String = "C:\j\WindowsApplication1.exe"
        If File.Exists(oldName) Then
            File.Move(oldName, newName)
            Dim lngMoveFile As Long
            lngMoveFile = MoveFile("C:\test.exe", My.Computer.FileSystem.SpecialDirectories.Desktop & Application.ExecutablePath)

I want my code to move an executeable file to the desktop, and I want the application to find the current file name, because I use "GetRandomFileName" to change the filename. I used:
Application.ExecutablePath
Why is that wrong?

What I have tried:

Dim newName As String = String.Format("{0}.exe", Path.GetRandomFileName().Replace(".", ""))
        Dim oldName As String = "C:\j\WindowsApplication1.exe"
        If File.Exists(oldName) Then
            File.Move(oldName, newName)
            Dim lngMoveFile As Long
            lngMoveFile = MoveFile("C:\test.exe", My.Computer.FileSystem.SpecialDirectories.Desktop & Application.ExecutablePath)
Posted 17-Jul-17 11:40am
Updated 17-Jul-17 11:58am
v5

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Nevermind:
lngMoveFile = MoveFile(My.Computer.FileSystem.SpecialDirectories.Desktop & "\" & IO.Path.GetFileName(Application.ExecutablePath), "C:\NAME.exe") 'paths of current and 
  Permalink  
Comments
PIEBALDconsult 17-Jul-17 18:03pm
   
Please don't answer your own question; just use "Improve question".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 17 Jul 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100