C#获取文件目录
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FileCatalog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy; //设置拖放操作中目标放置类型为复制
String[] str_Drop = (String[])e.Data.GetData(DataFormats.FileDrop, true);//检索数据格式相关联的数据
MessageBox.Show(str_Drop[0]);
}
}
}
Form1.Designer.cs
namespace FileCatalog
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// Form1
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 99);
this.Name = "Form1";
this.Text = "获取文件目录";
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter);
this.ResumeLayout(false);
}
#endregion
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace FileCatalog
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
C#获取文件目录的更多相关文章
- python 获取文件目录位置
test.py import os print('***获取当前目录***') print(os.getcwd()) print(os.path.abspath(os.path.dirname(__f ...
- shell中获取文件目录方法
1.``:表示执行对应的命令,嵌套时使用`\`\``,注意\进行转义,同时执行多个命令时使用:隔开file=`cd "\`dirname $0\`";pwd`echo $file ...
- PHP获取文件目录dirname(__FILE__),getcwd()
以discuz x2.5为例 D:/www/upload2.5/test.php D:/www/upload2.5/source/class/class_test.php test.php文件如下 & ...
- java中获取文件目录
1. web项目得到部署的目录路径(最后包含"/"或"\"): xxx(HttpServletRequest request) { String strDirP ...
- Windows 下c获取文件目录
由于要插数据库,构建sql语句,需要文件名,在网上找了半天,无奈都是Linux下的专用函数,伤心,,还有那个下载URL ,还木搞好,就要走啦,心焦哇 #include<iostream> ...
- Java学习-009-文件名称及路径获取实例及源代码
此文源码主要为应用 Java 获取文件名称及文件目录的源码及其测试源码.若有不足之处,敬请大神指正,不胜感激!源代码测试通过日期为:2015-2-3 00:02:27,请知悉. Java获取文件名称的 ...
- 详解php 获取文件名basename()函数的用法
PHP 中basename()函数给出一个包含有指向一个文件的全路径的字符串,此函数返回基本的文件名,本篇文章收集了关于使用PHP basename()函数获取文件名的几篇文章,希望对大家理解使用PH ...
- IndexOf、LastIndexOf、Substring的用法及C# foreach 中获取索引index的方法
String.IndexOf String.IndexOf 方法 (Char, Int32, Int32)报告指定字符在此实例中的第一个匹配项的索引.搜索从指定字符位置开始,并检查指定数量的字符位置 ...
- System.getProperty("user.dir")获取的到底是什么路径?
一直用System.getProperty("user.dir")来获取文件目录,我在执行单个方法调试和执行测试脚本的时候碰到一个问题, 我写了一个类ElementInitiali ...
随机推荐
- nodejs高并发大流量的设计实现,控制并发的三种方法
nodejs高并发大流量的设计实现,控制并发的三种方法eventproxy.async.mapLimit.async.queue控制并发Node.js是建立在Google V8 JavaScript引 ...
- wm_concat函数oracle 11g返回clob
用wm_concat连接拼接字符串,测试环境是10g,一切正常 到了生产环境是11g,点开直接报错了 wm_concat函数在oracle 10g返回的是字符串,到了11g返回的是clob 解决办法: ...
- K8S学习笔记之ETCD启动失败注意事项
最近搭建K8S集群遇到ETCD的报错,报错信息如下,一定要关闭防火墙.iptables和SELINUX,三个都要关闭!! Mar 26 20:39:24 k8s-m1 etcd[6437]: heal ...
- Python3 tkinter基础 Menubutton 点击按钮出现下拉菜单
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 获取Tomcat更详细的日志
前言 有时候tomcat报错未详细,未能定位到原因. 解决方法: 获取更详细的日志,以便调试. 详细步骤: 获取详细的日志,方法如下: 在WEB-INF/classes目录下logging.pro ...
- Machine Learning--week2 多元线性回归、梯度下降改进、特征缩放、均值归一化、多项式回归、正规方程与设计矩阵
对于multiple features 的问题(设有n个feature),hypothesis 应该改写成 \[ \mathit{h} _{\theta}(x) = \theta_{0} + \the ...
- Bytom 技术 FAQ
比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom 1.如何 ...
- freecodecamp数字转化成罗马数字
做数字转罗马数字时,用到了贪心算法,很好用,记录一下,有时间系统的学一下 罗马数字的规则: 罗马数字网址 1 5 10 50 100 500 1000 I V X L C D M1 1当一个符号在一个 ...
- Spring中 @Autowired标签与 @Resource标签
spring不但支持自己定义的@Autowired注解,还支持由JSR-250规范定义的几个注解,如:@Resource. @PostConstruct及@PreDestroy. @Autowired ...
- pycharm鸡火
由于github被封杀,大虾把它挪到了gitee下面 /pengzhile/jetbrains-agent 主要是一个jar包,放在D:\Program Files\JetBrains\PyCharm ...