Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving to a folder in the users "My documents"

Tags:

.net

vb.net

When I create the installer for my application I am going to be creating a folder in their "My Documents", this folder is going to be used to save files from my application into.

I would like to have my application automatically pull up this directory when the save file & open file dialogs open. Now my question is, what is the string I need to use to get to a folder in their "My documents"?

I know to get their my documents directory it goes something like this:

Dim dir as String  
dir = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) 

But how about a folder in their my documents? Such as My Documents/Coolest Application Ever Files. This project is in VB.net.

Thanks in advance.

like image 813
user1632018 Avatar asked Oct 25 '12 20:10

user1632018


People also ask

What is the default location where you save your Documents?

The Documents folder is the default working folder for all of the files that you create in your Microsoft Office programs. You can choose a different default working folder.

How do you help your users save files?

You help your users by remembering where the last file was stored they don’t have to navigate their entire folder structure every time they want to save a file. So far so good.

How to restrict user to save files to desktop folder?

Please guide us to restrict user to save files to desktop,documents and other folder through group policy. Thanks for your question. 1. Create a Group Policy Object, go to Computer Configuration > Policy > Windows Settings > Security Settings > File System 2.

How to access the Documents folder in Windows 10?

To access the Documents folder in Windows 10, you can use the following three ways: Way 1: Using File Explorer Click on the Folder looking icon on the Taskbar to open File Explorer. Under Quick access on the left side, there must be a folder with name Documents.

How do I get a list of all my saved documents?

Way 1: Using File Explorer Click on the Folder looking icon on the Taskbar to open File Explorer. Under Quick access on the left side, there must be a folder with name Documents. Click on it, and it will show all the documents you earlier had or have saved recently.


4 Answers

Have a look at Path.Combine.

dir = Path.Combine(dir, "Coolest Application Ever Files")

Just ensure it exists before your try to write to a file there.

If Not Directory.Exists(dir) Then
  Directory.Create(dir)
End If
like image 169
Daniel A. White Avatar answered Oct 03 '22 03:10

Daniel A. White


Dim filepath As String
filepath= IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "test.txt")
like image 33
Ng'onga Ngosa Avatar answered Oct 03 '22 03:10

Ng'onga Ngosa


Well, if you are creating the folder in the "My Documents" folder, can you just assume that you already know the name of said folder? So wouldn't:

dir = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments & "\Your_Folder_Title\")

work?

like image 45
burmat Avatar answered Oct 03 '22 03:10

burmat


Just append the folder you're looking for to the MyDocuments special folder

dir = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments & "/Coolest Application Ever Files") 
like image 37
AntLaC Avatar answered Oct 03 '22 05:10

AntLaC