Excel文件未保存在正确的路径中 [英] Excel file is not saving in correct path

查看:86
本文介绍了Excel文件未保存在正确的路径中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下c#代码将excel文件保存在应用程序启动路径文件夹中.但是它保存在我的文档"文件夹中.有人可以解释一下吗?
谢谢

I''m using the following c# code to save an excel file in the application start-up path folder. But it''s saving in ''My Documents'' Folder. Can someone please explain?
Thank you

string dailyFile = "DeliveryChallan(" + date + time + ").xls";

File.Copy(Application.StartupPath + "\\DCTemplate.xls", 
    Application.StartupPath + dailyFile);

Microsoft.Office.Interop.Excel.Application xlApp;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;

object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.ApplicationClass();
xlWorkBook = App.Workbooks.Open(Application.StartupPath + dailyFile,
    misValue, misValue, misValue, misValue, misValue, 
    misValue, misValue, misValue, misValue, misValue, 
    misValue, misValue, misValue, misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

xlWorkBook.Save();
xlApp.Workbooks.Close();
xlApp.Quit();

推荐答案

权限不足?如果是Vista或更高版本,请尝试以管理员身份运行.
Insufficient rights? If it is Vista or later, try running as admin.


这篇关于Excel文件未保存在正确的路径中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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