客户端文件操作问题

因为权限原因,我需要只打开而不下载,只在客户端显示文件(word,excel,ppt,txt),在网上找了一天都没找到解决的办法,所有的方法都是打开和下载同时存在,有没有什么方法可以只打开文件而不可下载的,只要把文件内容在客户端显示出来就行,最好可提供源代码(C#),请各位大哥帮帮忙了

-------------------------------------------------

做个ActiveX控件或JavaBean

-------------------------------------------------

我试过excel的:
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + filename + "';Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection(mystring);
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
this.dtgShow.DataSource = myDs.Tables[0];
this.dtgShow.DataBind();
但是报错啊,说sheet1$不存在

-------------------------------------------------

下面的是读WORD的文件内容:
private void Button1_Click(object sender, System.EventArgs e)
{
string strError = "";
Word.Document wDoc=null;
Word.Application wApp=null;
object missing=System.Reflection.Missing.Value;
CreateWordDocument(@"F:/新建文件夹/123.doc",ref wDoc,ref wApp,ref strError);
string str = strError;
TextBox1.Text=wDoc.Content.Text;
}
public static void CreateWordDocument(string FileName, ref Word.Document wDoc,ref Word.Application WApp,ref string strError)
{
if(FileName=="") return;
Word.Document thisDocument=null;

Word.FormFields formFields=null;
Word.ApplicationClass thisApplication=new Word.ApplicationClass();
thisApplication.Visible=true;
thisApplication.Caption="";
thisApplication.Options.CheckSpellingAsYouType=false;
thisApplication.Options.CheckGrammarAsYouType=false;

Object filename=FileName;
Object ConfirmConversions=false;
Object ReadOnly=true;//true;
Object AddToRecentFiles=false;
Object PasswordDocument = System.Type.Missing;
Object PasswordTemplate = System.Type.Missing;
Object Revert = System.Type.Missing;
Object WritePasswordDocument = System.Type.Missing;
Object WritePasswordTemplate = System.Type.Missing;
Object Format = System.Type.Missing;
Object Encoding = System.Type.Missing;
Object Visible = System.Type.Missing;
Object OpenAndRepair = System.Type.Missing;
Object DocumentDirection = System.Type.Missing;
Object NoEncodingDialog = System.Type.Missing;
Object XMLTransform = System.Type.Missing;
object missing=System.Reflection.Missing.Value;
try
{
Word.Document wordDoc =
thisApplication.Documents.Open(ref filename, ref ConfirmConversions,
ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate,
ref Revert,ref WritePasswordDocument, ref WritePasswordTemplate, ref Format,
ref Encoding, ref Visible, ref OpenAndRepair, ref DocumentDirection,
ref NoEncodingDialog );//, ref XMLTransform 
thisDocument = wordDoc;
wDoc = wordDoc;
WApp = thisApplication;
formFields = wordDoc.FormFields;
}
catch(Exception ex)
{
strError=ex.Message;
throw new Exception("操作word时出现异常!");
}

-------------------------------------------------

ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}/ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。

权限的问题该怎么解决啊

-------------------------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值