tags:

views:

31

answers:

0

I have a webservice application .That application did attach a file from remote machine and detach file from local machine.

Its code is as follows

    private void attachFile(string file, SoapContext context)
    {
        System.IO.FileStream fs = System.IO.File.OpenRead(file);
        DimeAttachment da = new DimeAttachment("image/jpeg", TypeFormat.MediaType, file);
        da.Id = "uri:" + Guid.NewGuid().ToString();
        context.Clear();
        context.Attachments.Add(da);
        fs.Close();
    }
    detachFile(SoapContext pContext, string pOutFile)
    {
        try
        {
            byte[] data = new byte[8192];
            int numBytes;
            if (pContext.Attachments.Count > 0)
            {
                System.IO.Stream stream = pContext.Attachments[0].Stream;
                System.IO.FileStream fstream = System.IO.File.OpenWrite(pOutFile);
                System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fstream);
                while ((numBytes = stream.Read(data, 0, data.Length)) > 0)
                {
                    bw.Write(data, 0, numBytes);
                }

                bw.Flush();
                fstream.Close();
                stream.Close();
                bw.Close();
                return true;
            }
       }

When I use soap context it takes long time (depends the size of the file).I want to replace FTP protocol instead of it .I wish to know how to do it.I am not intersested to change the behaviour of this function.Using the same functionality I wish to know how to replace soap context with FTP?