将本地pdf复制到网络服务器上的文件夹 [英] copy local pdf to folder on network server
本文介绍了将本地pdf复制到网络服务器上的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在编写一个asp.net 4.0 Web应用程序.http://server/webscan/
我的应用程序使用activex控件进行扫描和图像处理,然后保存到本地磁盘c:\ temp.pdf.
我需要使用此文件夹中的代码将该文件传输或复制到服务器
http://server/webscan/temp/
我不想使用fileupload选项.
有什么选择吗?
非常感谢
Anoop
Hi guys,
i am writing an asp.net 4.0 web application.http://server/webscan/
my application scans and image using a activex control and saves onto the local disk c:\temp.pdf.
i need this file to be transfer or copied to the server using code into this folder
http://server/webscan/temp/
i dont want to use the fileupload option.
are there any options?
thanks alot
Anoop
推荐答案
如果您可以访问activex控件中的代码,我建议您研究一下在其中放置一些推送到服务器"的代码.这样,您可以执行操作而无需用户做任何额外的事情.我还建议您创建一个Web服务,以供ActiveX控件使用以传输文件.
要通过Web服务接收大量数据,请参见: http://msdn.microsoft. com/en-us/library/aa528822.aspx [ ^ ]
If you have access to the code in the activex control, I would suggest to investigate putting some "push to server" code in there. That way you could perform the action without requiring the user to do anything extra. I would also suggest that you create a web service for the activeX control to consume in order to transfer the file.
To receive large amounts of data through a web service see this: http://msdn.microsoft.com/en-us/library/aa528822.aspx[^]
using System;
using System.IO;
class Test
{
public static void Main()
{
// Specify a file to read from and to create.
string pathSource = @"c:\tests\source.txt";
string pathNew = @"c:\tests\newfile.txt";
try
{
using (FileStream fsSource = new FileStream(pathSource,
FileMode.Open, FileAccess.Read))
{
// Read the source file into a byte array.
byte[] bytes = new byte[fsSource.Length];
int numBytesToRead = (int)fsSource.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = fsSource.Read(bytes, numBytesRead, numBytesToRead);
// Break when the end of the file is reached.
if (n == 0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
numBytesToRead = bytes.Length;
// Write the byte array to the other FileStream.
using (FileStream fsNew = new FileStream(pathNew,
FileMode.Create, FileAccess.Write))
{
fsNew.Write(bytes, 0, numBytesToRead);
}
}
}
catch (FileNotFoundException ioEx)
{
Console.WriteLine(ioEx.Message);
}
}
}
这篇关于将本地pdf复制到网络服务器上的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文