
如果只是需要看一个文件的路径,右键 get info (cmd + i)可以看到。
另一种方便的方法是,打开 terminal,把文件拖进terminal 窗口,自动显示路径。
如果需要复制路径,在finder里,对选中的文件,cmd+opt+c,就复制到剪贴板了。
最近在爆个插件,有个需求就是能够在Solution Explorer中右键点击某个文件然后做一些下流的 *** 作,那么首先就要想办法得到用户选择的文件或者文件们。肿么搞呢。研究了一下WebEssential的代码,总结了一下:
首先,你需要获得DTE2对象,貌似指的是你当前的VS实例。为了方便使用定义成一个静态属性,放到package类里面:
也就是继承Package类的那个类,比如public sealed class ForeverAlonePackage : Package
private static DTE2 _dte;
internal static DTE2 DTE
{
get
{
if (_dte == null)
_dte = ServiceProviderGlobalProviderGetService(typeof(DTE)) as DTE2;
return _dte;
}
}
然后就可以写个助手类,用来获得当前选中的文件(们)了:
///<summary>Gets the full paths to the currently selected item(s) in the Solution Explorer</summary>
public static IEnumerable<string> GetSelectedItemPaths(DTE2 dte = null)
{
var items = (Array)(dte 你的PACKAGE类DTE)ToolWindowsSolutionExplorerSelectedItems;
foreach (UIHierarchyItem selItem in items)
{
var item = selItemObject as ProjectItem;
if (item != null && itemProperties != null)
yield return itemPropertiesItem("FullPath")ValueToString();
}
}
至于路径,稍微处理一下就行:
///<summary>Gets the paths to all files included in the selection, including files within selected folders</summary>
public static IEnumerable<string> GetSelectedFilePaths()
{
return GetSelectedItemPaths()
SelectMany(p => DirectoryExists(p)
DirectoryEnumerateFiles(p, "", SearchOptionAllDirectories)
: new[] { p }
);
}
另外,如果要获取选中的项目文件,可以这样:
///<summary>Gets the the currently selected project(s) in the Solution Explorer</summary>
public static IEnumerable<Project> GetSelectedProjects()
{
var items = (Array)你的PACKAGE类DTEToolWindowsSolutionExplorerSelectedItems;
foreach (UIHierarchyItem selItem in items)
{
var item = selItemObject as Project;
if (item != null)
yield return item;
}
}
获取解决方案(sln)的根目录:
///<summary>Gets the directory containing the active solution file</summary>
public static string GetSolutionFolderPath()
{
EnvDTESolution solution = 你的PACKAGE类DTESolution;
if (solution == null)
return null;
if (stringIsNullOrEmpty(solutionFullName))
return GetRootFolder();
return PathGetDirectoryName(solutionFullName);
}
这些代码在VS2010 SDK里也能用。
望采纳
首先在窗体中放置 Microsoft Common Dialog Control,名称指定为 cdlg1。
然后放一个按钮,代码如下:
Private Sub Command1_Click()
Dim fname As String
Dim content As String
cdlg1ShowOpen
fname = cdlg1FileName
MsgBox fname
Open fname For Input As #1
Input #1, content
MsgBox content
Close #1
End Sub
# 接收表单提交变量
$file=$_FILES['BtnPic'];
//print_r($_FILES);PRINT_R($file);
//PRINT_R($file);
//判断文件是否上传成功
if(is_uploaded_file($file['tmp_name'])){
//apache文件上传时临时储存路径,移动到自定义路径
$upload_file=$file['tmp_name'];
//print_r($upload_file);
$uploadpath = $_SERVER['DOCUMENT_ROOT']"/UploadFile/naotu/";//这块要注意一下路径
//下面是你服务器储存文件的路径,可以自定义
$move_to_file=$uploadpath$file['name'];
//判断是否移动成功
if (!is_dir($uploadpath)){
mkdir($uploadpath,0777,true);
}
if(move_uploaded_file($upload_file,$move_to_file)){
echo "上传文件成功";
}else{
echo "上传失败";
}
}else{
echo "上传失败请检查服务器。";
}
以上就是关于MAC怎么获取文件路径全部的内容,包括:MAC怎么获取文件路径、如何获取Solution Explorer中选中的文件路径、vb 选择文件 获取文件路径等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)