special-folders

Check if DirectoryInfo.FullName is special folder

大憨熊 提交于 2019-12-22 12:16:06
问题 My goal is to check, if DirectoryInfo.FullName is one of the special folders. Here is what I'm doing for this (Check directoryInfo.FullName to each special folder if they are equal): DirectoryInfo directoryInfo = new DirectoryInfo("Directory path"); if (directoryInfo.FullName == Environment.GetFolderPath(Environment.SpecialFolder.Windows) || directoryInfo.FullName == Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles ||) ... ... ) { // directoryInfo is the special folder } But

How to specify log file path using folder locations in Windows with log4net xml configurator?

依然范特西╮ 提交于 2019-12-22 03:19:16
问题 In my app.config I put <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="%programdata%/log-file.txt"/> but it didn't work. Any ideas? 回答1: The log4net syntax for expanding environment variables is "${Variable}" e.g. <file value="${LOCALAPPDATA}\GojiSoft\GojiLog\log.txt" /> 回答2: Resurrecting an old thread here, but I encountered the same issue and thought I'd share. ${PROGRAMDATA}, as discussed in the comment thread of the other answer, didn't work

Find windows folder programmatically in c#

倾然丶 夕夏残阳落幕 提交于 2019-12-20 09:57:21
问题 I am writing a program to kill and restart explorer but I don't want to hard code the location because some people install windows in different places (for example I found someone who had it installed in the d:\ drive where the C:\ drive did exist but had nothing installed on it) I tried looking under Environment.SpecialFolder. but I don't see a "windows" option under that What is the best way to do this? 回答1: http://msdn.microsoft.com/en-us/library/77zkk0b6.aspx Try these: Environment

Function for getting localized path?

不羁岁月 提交于 2019-12-18 06:13:16
问题 Windows 7 (and probably Windows Vista) display localized folder names using the LocalizedResourceName entry in the desktop.ini file. For my Documents folder, this looks like [.ShellClassInfo] LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21770 IconResource=%SystemRoot%\system32\imageres.dll,-112 IconFile=%SystemRoot%\system32\shell32.dll IconIndex=-235 (see this question) This way the explorer displays the path "C:\Users\Username\Documents" as "C:\Benutzer\Username\Dokumente" on a

How to create shortcut to Computer on the user's desktop

我是研究僧i 提交于 2019-12-18 05:15:58
问题 I am working on a VBScript that is to show the "Computer" icon on the desktop. I've been able to do one for IE using the following code, however as Computer is a "Special Folder" that does not seem to have an actual location I can't use the same method. Would anyone have any idea how to enable it via VBScript? IE Shortcut code: Set objShell = WScript.CreateObject("WScript.Shell") 'Create Shortcut for IE on desktop allUsersDesktop = objShell.SpecialFolders("AllUsersDesktop") usersDesktop =

What's the difference between SpecialFolder.Desktop and SpecialFolder.DesktopDirectory?

让人想犯罪 __ 提交于 2019-12-17 15:46:52
问题 I'm confused about the differences between these two special folders. Here's a code snippet that writes the output of each, but they output the same thing. string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string pathTwo = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); Console.WriteLine(path); Console.WriteLine(pathTwo); Console.ReadKey(); According to the MSDN documentation ( for .NET 1.1 ): Desktop The logical Desktop rather than the

As a developer, how should I use the special folders in Windows Vista (and Windows 7)?

混江龙づ霸主 提交于 2019-12-17 15:38:52
问题 Where should I save data related to my application? Where should I save configuration files? Where should I save temporary files? Should I do it in "Documents"? "AppData"? Etc... What is the best practice for saving data to the disk (I guess, best practice for special folders?!)? 回答1: ApplicationData : Everything that your application needs as "per user" data and does not fall under other categories. Standard configuration files would go here. CommonApplicationData : Everything that is not

How to programmatically derive windows downloads folder “%USERPROFILE%/Downloads”?

大憨熊 提交于 2019-12-17 05:09:41
问题 In .Net we can retreive the paths to 'special folders', like Documents/Desktop etc. Today I tried to find a way to get the path to the 'Downloads' folder, but it's not special enough it seems. I know I can just do 'C:\Users\Username\Downloads', but that seems an ugly solution. So how can I retreive the path using .Net? 回答1: The problem of your first answer is it would give you WRONG result if the default Downloads Dir has been changed to [Download1]! The proper way to do it covering all

How to programmatically derive windows downloads folder “%USERPROFILE%/Downloads”?

强颜欢笑 提交于 2019-12-17 05:08:33
问题 In .Net we can retreive the paths to 'special folders', like Documents/Desktop etc. Today I tried to find a way to get the path to the 'Downloads' folder, but it's not special enough it seems. I know I can just do 'C:\Users\Username\Downloads', but that seems an ugly solution. So how can I retreive the path using .Net? 回答1: The problem of your first answer is it would give you WRONG result if the default Downloads Dir has been changed to [Download1]! The proper way to do it covering all

Visual Studio Solution — Any way to create a “special” folder?

和自甴很熟 提交于 2019-12-14 03:43:27
问题 Basically, I want one of my folders to appear above the other folders as a type of "special folder", similar to how Properties has it's own special place even though it's a folder, same with App_Data, etc. Is this possible? 回答1: By default, Visual Studio doesn't support adding special project folders. The Properties folder is hard-coded to behave the way that it does. However, anything is possible with code. You could build an extension to do this, but it wouldn't be simple. You'd probably