Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is it possible to code an application that creates a folder in the temp directory, and then moves the application to the folder? Or that when the application executes, it is saved in the folder?

What I have tried:

If Not Directory.Exists(folder_name) Then
 
            Directory.CreateDirectory(folder_name)
 
        End If
Posted
Updated 16-Jul-17 9:15am
Comments
Patrice T 16-Jul-17 14:52pm    
In 3 question, you ask how to change extension, change name, move app in subdirectory of temp.
What do you try to do exactly ?
[no name] 16-Jul-17 15:07pm    
I am trying to create a file pitcher
Dave Kreskowiak 16-Jul-17 15:12pm    
What the hell is a "file pitcher"?

[no name] 16-Jul-17 15:18pm    
A tool that I am trying to create for my company.
Dave Kreskowiak 16-Jul-17 15:21pm    
No sh*t. WHAT DOES A "FILE PITCHER" DO??

1 solution

Sure, it's possible to create a folder in one of the Temp folders.

Moving the application? Why? There's no reason to do that.

Also, if your app is installed under Program Files, which it should always be, normal users do not have permissions to MOVE the application files to another folder. They can be COPIED, but that's it.

Also, the executables that are running cannot be MOVED. Once an .EXE is running and the .DLL's it is currently using are loaded into the process, the files become locked and cannot be moved or deleted.

So, what are you really trying to do because none of this makes any sense.
 
Share this answer
 
Comments
[no name] 16-Jul-17 15:38pm    
The file can be moved to .TEMP while it is running? I tested it out myself with my application. Also, do you know how to create a folder in Temp folder, and make the folder have a custom name? Because I can make a folder in the Temp, but can't edit the folder's name in the code. I want to use Path.GetTempPath. Thanks for helping me out man!
Dave Kreskowiak 16-Jul-17 17:00pm    
An executable can be COPIED, NOT MOVED, while it is running.

There are three TEMP folders, not all of which can be interacted with by a normal user. The one under C:\Windows\Temp is not usable by normal users.

The temp folder path that Path>GetTempFolder returns in one of the ones a normal user can use, under the user profile Local Temp folder.

creates a folder in the temp directory, and then moves the application to the folder
Why on earth would you move your application to the temp folder?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900