有另一种思路,可以将word另存为html后再用asp读取并显示
如果硬要用asp直接读word,最大限度只能读文本 代码如下:
<SCRIPT LANGUAGE= "JavaScript ">
<!--
var FileSource;
var FileDesource;
var word;
var xml>用FTP的形式上传即可,不限制文件格式
以下所有需要修改的地方用表示,先修改掉再用
string serverName = ""; //写你服务器IP,别直接用。。。
// This example assumes the site uses anonymous logon
NetworkCredential credentials = new NetworkCredential("anonymous", ""); //写你的FTP用户名密码
DemonstrateWebClient(serverName,credentials,filename,ftpdir);//然后调用上传方法,filename是你想要上传的文件名称,ftpdir是上传到服务器的哪个文件夹中
private static void DemonstrateWebClient(string serverName, NetworkCredential credentials, string filename, string ftpdir)
{
string serverAddress = "ftp://" + serverName + "/" + ftpdir+"/"; //注意这里的格式,很容易在前面定义错
// Create a new WebClient object and set the credentials
WebClient webClient = new WebClient();
webClientCredentials = credentials;
//// Download file
//try
//{
// string fileName = ReadFileName("download");
// string downloadAddress = serverAddress + fileName;
// ConsoleWriteLine("Downloading file " + downloadAddress);
// // The string passed in should include the URI path that has
// // the file name to be downloaded
// webClientDownloadFile(downloadAddress, fileName);
//}
//catch (WebException ex)
//{
// ConsoleWriteLine(exMessage);
//}
// Upload file
try
{
string fileName = filename;
string uploadAddress = serverAddress + fileName;
//ConsoleWriteLine("Uploading file " + uploadAddress);
webClientUploadFile(uploadAddress, "//"+fileName);//上传文件所在的本地路径在这里修改
}
catch (WebException ex)
{
//ConsoleWriteLine(exMessage);
MessageBoxShow(exMessage, "Upload failed");
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)