Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5964721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:29:06+00:00 2026-05-22T19:29:06+00:00

I have a small upload application where i upload a file using a webservice

  • 0

I have a small upload application where i upload a file using a webservice (asmx), check the MD5 and verify it. Problem is that when i verify the file it says that the file is locked by another process. Below is my code for uploading and verifying:

private static object padlock = new object();

Chunking the upload file in smaller bites and uploading each of them

[WebMethod]
        public void LargeUpload(byte[] content, string uniqueName)
        {
            lock (padlock)
            {
                string path = Server.MapPath(PartialDir + "/" + uniqueName);
                BinaryWriter writer = new BinaryWriter(File.Open(path, FileMode.Append, FileAccess.Write));
                writer.Write(content);
                writer.Flush();
                writer.Close();
                writer = null;
            }
        }

After the last one insert it into my database. After this the client verifies the file by requesting the MD5:

[WebMethod]
        public int EndLargeUpload(string name, int folderId, long length, string uniqueName, int customerid)
        {
            lock (padlock)
            {
                string path = Server.MapPath(PartialDir + "/" + uniqueName);
                string newPath = Server.MapPath(RepositoryDir + "/" + uniqueName);
                File.Copy(path, newPath);
                //delete partial
                File.Delete(path);
                string extension = Path.GetExtension(uniqueName);
                string newFileName = uniqueName;
                GWFile newFile = new GWFile();
                newFile.DiscName = newFileName;
                newFile.FileName = name;
                newFile.FolderId = folderId;
                newFile.Description = "";
                newFile.Size = (int)length;
                newFile.DiscFolder = Server.MapPath("/Repository");
                newFile.DiscRelativePath = "/Repository/" + newFile.DiscName;
                newFile.CustomerId = customerid;
                IGWFileRepository fileRepository = ObjectFactory.GetInstance<IGWFileRepository>();


                fileRepository.SaveFile(newFile);
                return newFile.Id;
            }
        }

After the EndLargeUpload() method the client calls the RequestMD5 method with the id of the file, this call excepts with an exception that it cannot open the file “…..xxx…” because it s being used by another process…

private string GetMD5HashFromFile(string fileName)
            {
                lock (padlock)
                {
                    using (FileStream file = new FileStream(fileName, FileMode.Open)) // <-- excepts here
                    {
                        MD5 md5 = new MD5CryptoServiceProvider();
                        byte[] retVal = md5.ComputeHash(file);
                        file.Close();

                        StringBuilder sb = new StringBuilder();
                        for (int i = 0; i < retVal.Length; i++)
                        {
                            sb.Append(retVal[i].ToString("x2"));
                        }
                        return sb.ToString();
                    }
                }
            }

I used the process explorer from sysinternals to view the file, it says that the file is locked by the web server ( pls refer to this img: http://screencast.com/t/oqvqWXLjku) – how can the web server lock it? can I work around this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:29:07+00:00Added an answer on May 22, 2026 at 7:29 pm

    Switched to IIS, and the problem seems to go away…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small application that does the following: allows the user to upload
we have a small flash component on our website/application to upload multiple files. This
I'm developing small FTP upload app. for mac (10.6 if it matters) Have problem
I have small problem with my .net 2.0 winforms application. I want to embed
I have small utility that does some processing on a file and changes the
I have a small python cgi script that accepts an image upload from the
I have a small php script which allows me to upload image file on
I have an application that allows users to upload images. The test case I
Say that I have an application where user can upload his avatar, and then
I have to develop a small application that will connect to a Linux server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.