winform获取文件名|c# winform获得服务器某个文件夹下的所有文件名

winform获取文件名|c# winform获得服务器某个文件夹下的所有文件名的第1张示图

㈠ C#,winform中下拉框combox的内容想读取桌面的文件夹名称

添加一个按钮,将这里这个函数的代码放在按钮单击事件的处理函数中。同时取消对CB的SelectedIndexChanged事件的响应。下拉框是空的,是因为1、你不能在处理CB的SelectedIndexChanged事件的函数中改变CB的Items集合的值。2、目录C:\Users\Desktop\test\中可能没有文件。

㈡ 客户端winform程序获取服务器指定路径下所有文件名,能直接下载过来更好,服务器运行.ASP程序

winform是CS结构。所以说像这样的程序你必须要用个服务端。当然哪如果你是用FTP的话就可以不要了。但服务器上必须开启ftp服务来响应你的客户端要求FTP的就不讲了。你上网查个FTP的例子就可以了。如果是自己搞服务端可以用远程对象来实现意思就是这个类在服务端实例一个出来专门用于执行的。客户端只要调用就行了。结果会返回给客户端的。如果你要样例请给我你的QQ。我好发给你

㈢ c# winform获得服务器某个文件夹下的所有文件名

C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表等using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Windows.Forms; namespace ConvertData{ class FtpUpDown { string ftpServerIP; string ftpUserID; string ftpPassword; FtpWebRequest reqFTP; private void Connect(String path)//连接ftp { // 根据uri创建FtpWebRequest对象 reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(path)); // 指定数据传输类型 reqFTP.UseBinary = true; // ftp用户名和密码 reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); } public FtpUpDown(string ftpServerIP, string ftpUserID, string ftpPassword) { this.ftpServerIP = ftpServerIP; this.ftpUserID = ftpUserID; this.ftpPassword = ftpPassword; } //都调用这个 private string[] GetFileList(string path, string WRMethods)//上面的代码示例了如何从ftp服务器上获得文件列表 { string[] downloadFiles; StringBuilder result = new StringBuilder(); try { Connect(path); reqFTP.Method = WRMethods; WebResponse response = reqFTP.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名 string line = reader.ReadLine(); while (line != null) { result.Append(line); result.Append("\n"); line = reader.ReadLine(); } // to remove the trailing '\n' result.Remove(result.ToString().LastIndexOf('\n'), 1); reader.Close(); response.Close(); return result.ToString().Split('\n'); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); downloadFiles = null; return downloadFiles; } } public string[] GetFileList(string path)//上面的代码示例了如何从ftp服务器上获得文件列表 { return GetFileList("ftp://" + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectory); } public string[] GetFileList()//上面的代码示例了如何从ftp服务器上获得文件列表 { return GetFileList("ftp://" + ftpServerIP + "/", WebRequestMethods.Ftp.ListDirectory); } public void Upload(string filename) //上面的代码实现了从ftp服务器上载文件的功能 { FileInfo fileInf = new FileInfo(filename); string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name; Connect(uri);//连接 // 默认为true,连接不会被关闭 // 在一个命令之后被执行 reqFTP.KeepAlive = false; // 指定执行什么命令 reqFTP.Method = WebRequestMethods.Ftp.UploadFile; // 上传文件时通知服务器文件的大小 reqFTP.ContentLength = fileInf.Length; // 缓冲大小设置为kb int buffLength = 2048; byte[] buff = new byte[buffLength]; int contentLen; // 打开一个文件流(System.IO.FileStream) 去读上传的文件 FileStream fs = fileInf.OpenRead(); try { // 把上传的文件写入流 Stream strm = reqFTP.GetRequestStream(); // 每次读文件流的kb contentLen = fs.Read(buff, 0, buffLength); // 流内容没有结束 while (contentLen != 0) { // 把内容从file stream 写入upload stream strm.Write(buff, 0, contentLen); contentLen = fs.Read(buff, 0, buffLength); } // 关闭两个流 strm.Close(); fs.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Upload Error"); } }

㈣ C# winform中 post方式上传附件后得到文件名

一些设置,如按一下按钮或超连结输入如打开网页打开网页的Index.aspx 我想表明的价值,你可以从winform的:MYDATA假设myData的= 16,您乘坐16 在网页超链接文本框里面应该改写为:Index.aspx的? MYDATA = 16 字符串MYDATA的=请求[“myData的”]; TextBox1.Text = MYDATA 这样就可以使打开的页面里面的文本框的值传递过来的MYDATA值等有任何疑问,请咨询

㈤ winform程序获取项目根目录

对于你的问题,我的理解为:你做了一个窗体程序,需要打开一张图片,然后存如你当前执行的文件同级目录下的一个叫img的文件夹里。就是要保存到相对的exe文件同级的img文件夹。而不是写死了的路径。在vs编写的程序,在debug文件夹里的文件就是你编写好的程序生成后产生的编译文件。可以将debug中的内容拷贝到其他位置去。也就是你做的应用程序了。运行其中的exe文件就可以。而要保存图片到你说所的根目录下,代码如下:获取根目录:Application.StartupPath;以下是代码,亲测可用: openFileDialog1.Filter = "图片|*.*"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { Image img = Image.FromFile(openFileDialog1.FileName); //文件名 string filename = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("\\") + 1); //文件保存文件夹路径,此处【 Application.StartupPath 】就是根目录 //string savepath = Application.StartupPath + "\\img\\";#region 保存路径为项目的根目录,从debug目录往上截取两级文件夹 string rootpath = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\")); rootpath = rootpath.Substring(0, rootpath.LastIndexOf("\\")); //文件保存文件夹路径 string savepath = rootpath + "\\img\\";#endregion //文件保存路径+文件名 string imgSavepath = savepath + filename; //判断是否存在img文件夹 if (Directory.Exists(savepath)) { //存在img文件夹 //判断该路径下是否已经存在同名文件 if (File.Exists(imgSavepath)) { //提示是否覆盖 if (DialogResult.Yes != MessageBox.Show("图片已存在!", "该图片已存在,是否覆盖原图片?", MessageBoxButtons.YesNo)) { //点击【否】,返回,取消操作。 return; } } } else { //不存在,在根目录下创建img文件夹 Directory.CreateDirectory(savepath); } try { Image im = img; Bitmap bit = new Bitmap(im); bit.Save(imgSavepath, System.Drawing.Imaging.ImageFormat.Bmp); MessageBox.Show("图片保存成功!"); } catch{}

㈥ C# Winform中如何获取文件路径

获取文件名方法:用System.IO.Path.GetFileName和System.IO.Path.GetFileNameWithoutExtension(无扩展名)的方法获取文件路径方法://获取当前进程的完整路径,包含文件名(进程名)。string str = this.GetType().Assembly.Location;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)//获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。string str = System.Diagnostics.Process.GetCurrentProcess().MainMole.FileName;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)//获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。string str = System.Environment.CurrentDirectory;result: X:\xxx\xxx (.exe文件所在的目录)//获取当前 Thread 的当前应用程序域的基目录,它由程序集冲突解决程序用来探测程序集。string str = System.AppDomain.CurrentDomain.BaseDirectory;result: X:\xxx\xxx\ (.exe文件所在的目录+”\”)//获取和设置包含该应用程序的目录的名称。string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;result: X:\xxx\xxx\ (.exe文件所在的目录+”\”)//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。string str = System.Windows.Forms.Application.StartupPath;result: X:\xxx\xxx (.exe文件所在的目录)//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。string str = System.Windows.Forms.Application.ExecutablePath;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)//获取应用程序的当前工作目录(不可靠)。result: X:\xxx\xxx (.exe文件所在的目录)

㈦ winform怎么获取服务器上的文件路径

WinForm是获取不到服务器上的文件路径的,否则太可怕了。 除非服务器通过Web服务的接口返回。

㈧ 在winform中怎么获取文件夹中所有的文件directory

既然知道带路径的那么使用Path.GetFileName(带路径的文件名)别忘了using System.IO;对于这个问题,你可以写个循环啊string[] s = Directory.GetFiles(DirFullPath, SearchPattern);string[] filename = new string[s.Length];for (int i = 0; i < s.Length; i++){filename[i] = Path.GetFileName(s[i]);}return filename;大概就是这个意思吧

㈨ C# winform中如何获取路径下的文件夹名

using System.IO;String[] dirs = Directory.GetDirectories(@"C:\");comboBox1.Items.AddRange(dirs);

未经允许不得转载:山九号 » winform获取文件名|c# winform获得服务器某个文件夹下的所有文件名

赞 (0)