在Windows应用程序中自动将文件存储在特定位置? [英] Store file in specific location automatically in windows application?

查看:72
本文介绍了在Windows应用程序中自动将文件存储在特定位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将zip文件存储在特定位置.不允许用户存储zip文件,他只能上传zip文件,系统会自动将文件存储在特定位置.以下是我的颂歌



i want to store zip file in specific location.user are not allowed to stored zip file, he can only upload zip file and system automatically store file at specfic location. below is my ocde



private void button2_Click(object sender, EventArgs e)
      {
          OpenFileDialog open1 = new OpenFileDialog();
          // image filters
          open1.Filter = "Document Files(*.RAR)|*.RAR";
          if (open1.ShowDialog() == DialogResult.OK)
          {

              // document file path
              txtdocumentuploda.Text = open1.FileName;

          }
      }

推荐答案

1.获取文件名(您已经拥有了)

2.使用以下链接获取文件的字节:

System.IO.File.ReadAllBytes [
1. Get the file name (You already have it)

2. Get the bytes of the file using the following link:

System.IO.File.ReadAllBytes[^]

3. Send the bytes of the file in a byte[] array and the file name to the uploaded server.

4. Write the bytes to the file in the path (The path you specified).


这篇关于在Windows应用程序中自动将文件存储在特定位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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