Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这段代码可以从树视图中的目录创建节点
if (file.Exists) { var nodes = node.Nodes.Add(file.Name); nodes.ImageIndex = nodes.SelectedImageIndex = 2; nodes.Tag = file.FullName; }
我还需要获取文件的完整路径才能以另一种形式使用它。我感谢您的所有创意帮助
尝试这个 :
string myFilePath = Path.GetFullPath(file.Name); //OR var fileInfo= new FileInfo(file.Name); fileInfo.DirectoryName;