Simple File Upload in C# .Net



Here are a few simple steps you can follow to upload files in C# ASP.Net using the File Upload Control in Visual Studio:
Step 1:
* Create the file upload control in the design view. The ID of my control is "File1".

Step 2:
*Here is the code to upload a file.


protected  string   uploadFile(string userid, string oldFileLocation)
{
    if (File1.PostedFile != null && File1.PostedFile.ContentLength>0)
    {
        string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
        string SaveLocation = Server.MapPath("Folder") + "\\" + userid + "_" + fn;
 
        if (!fn.EndsWith(".doc") && !fn.EndsWith(".pdf") && !fn.EndsWith(".docx"))
        {
            return "Invalid File Type!";
        }
 
        if (!string.IsNullOrEmpty(oldFileLocation))
        {
            System.IO.File.Delete(oldFileLocation);
        }
 
        File1.PostedFile.SaveAs(SaveLocation);
        return "File Uploaded!";
    }
}



Note:
*I have used "userid" to ensure that uploaded files have unique names.
*I have created a folder "Folder" to save files into.
*I have added a check for the format of the uploaded file. You can vary the valid file type.
*I have also done a check to delete the existing file for that user.
Read more >>

2010 Summer Internship

I just finished with my Summer Internship at a Software firm: Prosix Softron Pvt. Ltd. 

The last 6 weeks of work were very interesting. I worked in C# ASP.Net to design web forms for several projects undertaken by the company. I learned to use Ajax and SQL as a part of development of online software systems. I gained knowledge about the important aspects of network security and learned to use various Visual Studio tools for the purpose of login, file upload, file export, report generation and many other. I worked in Visual Studio Environment with SQL Management Server. It was a great learning experience both at the personal and the professional level.

Prosix Softron is an IT Services and Solutions provider established in 1988 in Lucknow, INDIA and now having it’s offices in Noida, Delhi and USA. Prosix has a wide ranging experience of application of Information Technology, involving software development, bulk data handling, sale & support of licensed software and hardware, facility management & application re-engineering. Solutions from Prosix have been widely appreciated in domains like Financial Institutions, Manufacturing, e-Governance, Railways and Defense.
Read more >>

Emergency Management System - CS2103

CS2103- Software Engineering was a very interesting module i took in my Year 1 Semester 2 of NUS life! This module teaches the basics of the process of software development and involves a major group project to be completed in a team of four people. In my year of study the project given to us was implementation of an Emergency Management System (EMS).

My group comprised of me and my three friends all year ones. Initially we felt that the module might be difficult to manage as we may face tough competition from the rest of the cohort which comprised mainly of year twos and above. However, as the semester progressed this module turned out to be interesting and manageable.

We used C# in Visual Studio 2010 beta, PHP and SQL to code our project. What I realized after taking this module is that Software development is more than just coding. We spent countless nights figuring out the workflow of our system, defining key terminologies and logically refining our system.

Though our Iteration 1 was pretty bad and we ended up with a "fair" grade, the way we picked ourselves from then on, is something I really feel proud of. We came back with a finished logical design of our system and a cool Command User Interface in Iteration 2 which was appreciated by our invigilators. This filled us with confidence that the battle is not over yet and we could still get ahead in the race.

After a period of 13 weeks what we produces as a team was something really good ( in the sense it was more than what we had expected from ourselves at the start of the semester). I recieved with an A Grade for this module. Really satisfied with how things went regarding this module. I am really thankful to my team for their super support and understanding (*hint* only they know what I mean here ;))

Here are a few screen shots of our K4 Emergency Management System:

Main Login


Admin Panel


Dispatcher Panel

Do contact me if you wish to know more.


Read more >>

This is Amulya Khare's blog cum website. You can know more about him by viewing his profile.

Read about his views and ideas on topics that grab his attention.

Also you can view his work and projects.

Included here are some resources and articles that you might find interesting or helpful.