Click here to Skip to main content
15,886,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 26-Sep-12 1:12am
v2

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.

[Edit] To receive large amounts of data through a web service see this: http://msdn.microsoft.com/en-us/library/aa528822.aspx[^]
 
Share this answer
 
v2
Comments
Anoop Brijmohun 26-Sep-12 10:02am    
Hi ,
thanks,
i have tried the webserver route in which i read the contents of the pdf file and send the string to the webservice.

Error: MaxRequest for string excceded...
seems like the string passed through is too long...

the pdf file can be large < 10mb, max 3-4 pages.

the push to server method....
do you have any code for this???
if i understand you correctly...
-pass server url to activex
-copy file to server url
-send server url back to webform.
fjdiewornncalwe 26-Sep-12 10:08am    
Take a look at my updated answer
C#
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);
    }
}
}
 
Share this answer
 
Comments
fjdiewornncalwe 26-Sep-12 9:37am    
My vote of 1. Sorry, but the OP isn't asking how to copy a file from 1 place to another on the same system. He is asking about uploading the file from client to server via web without user interaction.
Anoop Brijmohun 26-Sep-12 10:03am    
you right Marcus,

not same machine,
copy local file to server folder.

thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900