上载文件时无法取得档案的路径名称 [英] Unable to get path name of the file when Uploading document

查看:109
本文介绍了上载文件时无法取得档案的路径名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在上传文档,但无法获取以下路径,即我编写的​​代码.

Hi to all,
I am uploading the document and unable to get path below is the code i.e I have written.

    Application app = new Application();

    Document doc = app.Documents.Open(FileUpload1.PostedFile.FileName);
    int all = 0;
    int countwords = doc.Words.Count;
    for (int i = 0; i <= countwords; i++)
    {
        string text = doc.Words[i].Text;
        all++;
    }
    Response.Write("<script>alert(" + all + ")</script>");

}
catch (Exception ee)
{
    Response.Write("<script>alert(" +ee.Message+ ")</script>");

}

推荐答案

不,它不能那样工作.
使用上载控件时,将从文件,文件名和文件类型中获取数据字节.然后,您可以保存数据或以适合您的其他任何方式对其进行操作.

您没有获得原始文件的完整路径,也无法访问该文件的用户原始文件以进行修改.
如果要使用路径将文件送入Documents.Open,则必须先将数据字节保存到服务器上的文件,然后将该文件的路径传递给方法.
No, it doesn''t work like that.
When you use an upload control, your get the bytes of data from the file, the file name, and the file type. You can then save the data or manipulating it in any other way that suits you.

You do not get the full path of the original file, you do not get access to the user original of the file for modifications.
If you want to feed the file into Documents.Open with a path, you must save the data bytes to a file on the server first, and then pass the path of that file to the method.


这篇关于上载文件时无法取得档案的路径名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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