也就是 一个固定文件 在项目里面
现在要把他用程序来保存在一个 自定义的路径下
要求如果有同名的文件 也不理 直接复盖掉原文件高手们请赐教、、、、新人问题见笑了!界面越简单 也就是一个 选择文件的对话窗
openFileDialog然后 一个 确定 按钮一点确定 就把内部指定的文件保存并复盖在到选择好的路径下在线等!

解决方案 »

  1.   

    File.Copy 方法 
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 
    http://feiyun0112.cnblogs.com/
      

  2.   

    File.Copy 方法 
      
    ***************************************************************************** 
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 
    http://feiyun0112.cnblogs.com/
      

  3.   

    小文件拷贝方法:
    private void button3_Click(object sender, EventArgs e)
            {
                //定义一个文件流,用于读取原文件
                FileStream fs = new FileStream(this.textBox1 .Text ,FileMode.Open );
                //定义内存缓冲区
                byte []buffer=new byte [(int)fs.Length ];
                //将文件读入到内存缓冲区中
                fs.Read(buffer ,0,buffer .Length );
                fs.Close();
     
                //定义一个文件流,用于将缓冲区中的文件流写入文件
                FileStream fs1 = new FileStream(this.textBox2 .Text ,FileMode.Create );
                //写入文件
                fs1.Write(buffer ,0,buffer .Length );
                fs1.Close();
            }
    大文件拷贝方法:
    private void CopyFile(string fromFile, string toFile, int lengthEachTime)
            {
                FileStream fileToCopy = new FileStream(fromFile, FileMode.Open, FileAccess.Read);
                FileStream copyToFile = new FileStream(toFile, FileMode.Append, FileAccess.Write);
                int lengthToCopy;
                if (lengthEachTime < fileToCopy.Length)//如果分段拷贝,即每次拷贝内容小于文件总长度
                {
                    byte[] buffer = new byte[lengthEachTime];
                    int copied = 0;
                    while (copied <= ((int)fileToCopy.Length - lengthEachTime))//拷贝主体部分
                    {
                        lengthToCopy = fileToCopy.Read(buffer, 0, lengthEachTime);
                        fileToCopy.Flush();
                        copyToFile.Write(buffer, 0, lengthEachTime);
                        copyToFile.Flush();
                        copyToFile.Position = fileToCopy.Position;
                        copied += lengthToCopy;
                    }
                    int left = (int)fileToCopy.Length - copied;//拷贝剩余部分
                    lengthToCopy = fileToCopy.Read(buffer, 0, left);
                    fileToCopy.Flush();
                    copyToFile.Write(buffer, 0, left);
                    copyToFile.Flush();
                }
                else//如果整体拷贝,即每次拷贝内容大于文件总长度
                {
                    byte[] buffer = new byte[fileToCopy.Length];
                    fileToCopy.Read(buffer,0,(int)fileToCopy.Length);
                    fileToCopy.Flush();
                    copyToFile.Write(buffer, 0, (int)fileToCopy.Length);
                    copyToFile.Flush();
                }
                fileToCopy.Close();
                copyToFile.Close();
            }
      

  4.   

                try
                {
                    File.Copy(sourceFile/*源文件*/, targetFile/*目标文件*/, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("文件操作失败: " + ex.Message);
                }