Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get user videos directory?

Tags:

c#

.net

winforms

I tried this:

userVideosDirectory = Directory.GetParent(Environment.GetFolderPath
                                 (Environment.SpecialFolder.ApplicationData)).FullName + "\\Videos";

But that give me:

C:\Users\username\AppData\Videos

But I don't have the directory AppData there only:

C:\Users\username\Videos

How do I get the Videos directory without the AppData ?

like image 964
Manuel Spechia Avatar asked Jul 07 '15 06:07

Manuel Spechia


3 Answers

You can get the videos folder using Environment.SpecialFolders.MyVideos property, and get the actual path to it using the Environment.GetFolderPath method.

string path = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);

Note that that enum contains many more folders you can get.

like image 84
Patrick Hofman Avatar answered Oct 12 '22 22:10

Patrick Hofman


Have you tried this?

string path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
like image 25
Stian Sandve Avatar answered Oct 12 '22 20:10

Stian Sandve


Something like that:

int userVideosDirectory = (Directory.GetParent(Environment.GetFolderPath
                                  (Environment.SpecialFolder.ApplicationData)).FullName + "\\Videos").IndexOf(@"\AppData\");

if (userVideosDirectory != 0)
{
    string str = (Directory.GetParent(Environment.GetFolderPath
                      (Environment.SpecialFolder.ApplicationData)).FullName + "\\Videos").Remove(userVideosDirectory, @"\AppData".Length);
}
like image 1
Thanos Markou Avatar answered Oct 12 '22 20:10

Thanos Markou