在Visual C#中获取打开的Windows文件夹的路径 [英] Getting path of open windows folder in Visual C#

查看:83
本文介绍了在Visual C#中获取打开的Windows文件夹的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好...
我到处搜寻了一些可以帮到我的东西,但找不到有用的东西.

我开发了一个小型Visual C#应用程序,将其嵌入到上下文菜单中(单击鼠标右键).
此应用程序的主要目的是将特定文件移动到特定文件夹中,为了更加清楚,我将举一些示例:

当我下载视频文件时,它们都进入同一个文件夹(D:\ Downloads \),然后每种类型的文件都有特定的文件夹.
(D:\ Folder \ Type1; D:\ Folder \ Type2; D:\ Folder \ Type3)应用程序所做的是将文件类型与文件夹匹配并将文件移至corespondent文件夹.一切进展顺利,该应用程序运行正常,但我有一个局限性,确实使我感到烦恼.问题是文件的移动位置是由我这样定义的:

Hello there...
I''ve searched all over the place for something that could help me but failed to find something helpfull.

I''ve developed a small Visual C# application, that i embebed into the context menu (right mouse button click).
The main purpose of this application is to move specific files into specific folders, i''ll give some example in order to be more clear:

When i download video files they all go into the same folder(D:\Downloads\) I then have specific folders for each type of file.
(D:\Folder\Type1; D:\Folder\Type2; D:\Folder\Type3) what the application does is it matches the type of file with the folder and move the files to the corespondent folders. All goes well and the application works fine but i have a limitation that really bugs me. The problem is that the location from where the files are moved is defined by me like this:

string InitDirectory = @"D:\\Downloading\\";
DirectoryInfo di = new DirectoryInfo(InitDirectory);



因此,我希望能够从当前打开的文件夹中移动文件.当我单击文件夹内的应用程序(在上下文菜单上)时,我想在我的附件中检测该文件夹路径,以便在该特定文件夹中搜索文件并将其移动.

我已经做了很多"System.Diagnostics.Process"类的挖掘工作,试图从进程(explorer.exe)中获取路径,但是没有运气.

任何人都可以向正确的方向寄给我.
我愿意为您提供有关此事的任何帮助.

在此先感谢:

Mike



So i want to be able to move files from the current open folder. When i click on my application(on the context menu) inside a folder, i want to detect that folder path inside my apllication in order to search for files in that specific folder and move them.

I''ve done alot of digging into "System.Diagnostics.Process" class trying to get the path from the process(explorer.exe) with no luck.

Can anyone send me in the right direction.
I''m open to any kind of help you can give me on this matter.

Thanks in Advance:

Mike

推荐答案

我不确定答案,但是我相信如果您给出相对路径,它将应用到当前文件夹中,所以可能是InitDirectory需要空白才能使它按您的意愿工作吗?
I''m not sure of the answer, but I believe if you give a relative path, it will apply it to the current folder, so perhaps InitDirectory needs to be empty for this to work as you''d like ?


我的意思是,如果您不指定路径,如果它告诉Windows复制myfolder \ myfile,它将会将该路径附加到当前位置,然后它将通过PATH变量(用于system32文件夹等已注册路径)进行工作,以查看是否可以在任何地方找到它.
I mean, if you don''t specify a path, if it tell windows to copy myfolder\myfile, it will append that path to the current location, then it will work through the PATH variable for registered paths like the system32 folder, to see if it can find it anywhere.


您好...
首先感谢您的关注.
相对路径是什么意思?
Hi there...
First of all thanks for the interest.
What do you mean with relative path?


这篇关于在Visual C#中获取打开的Windows文件夹的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆