读取特殊系统文件夹路径
函数result = getSpecialFolder(arg)返回特殊的系统文件夹,如“Desktop”,“MyMusic”等。% arg可以是此链接中提到的任何一个enum元素% http://msdn.microsoft.com/library/% system.environment.specialfolder.aspx%。% >> getSpecialFolder('Desktop')%% ans =% C:\Users\jsmith\Desktop获取SpecialFolder enum类型,这是一个嵌套enum类型。specialFolderType = System.Type.GetType(...的系统。环境+ SpecialFolder ');获取所有SpecialFolder枚举值的列表folders = system .枚举. getvalues (specialFolderType);enumArg = [];查找用户请求的匹配enum值为I = 1:表示文件夹。长度如果(strcmp(char(folders(i)), arg)) enumArg = folders(i);打破结束结束%验证如果(isempty (enumArg)错误(无效的参数的)结束调用GetFolderPath方法并返回结果result = System.Environment.GetFolderPath(enumArg);结束