.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

replacing or removing an existing file in asp.net

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net

i wanna make a system through which a file uploaded replaces a file on the same location and with the same name. how can i do it. please help

View Complete Post

More Related Resource Links

How to replace a file with existing file in SPDocument libray for an SPItem through Object model...

Hello All, Step1: I have created an SPItem in document libray by choosing a file through object model. Step2: Now i want to replace the existing file of the same SPItem with new file. How can i achieve this using SP Object model. Thanks in advance...

Adding New Column to XSD File Without Remapping existing Transformations

Hello, I am loading XML file using SQL 2005 SSIS and using XSD file for XML Schema defination. Now I have a requirement where I should add couple of new columns in XSD as the XML (MAY) have extra columns for few of its tables. Is it safe to add new columns to XSD and the Map only new columns in Data Flow and all will work? or after I add new columns I need to redesign all mappings as Column order will change. (I think SSIS refere a numeric value for each column, if Yes how can I add new column with less impact)? Thanks, Prabhat Nath

Add line to existing xml file


Hello every one I have tried to add some line to existing xml file but every time that i did it previous lines was replaced by new one

i tried to use dataset,streamreader and ... but i couldnt,


please help me  

How to associate STP file to an existing site in same farm.




single farm


there are 2 web-applications: web-app1, web-app2.


Each webapp has one site collection. that is 


webapp1 has site-collect1


webapp2 has site-collect2


Now for some reason I want to copy site-collect2 to webapp1 as site-collect1.


content-db doesn't work because of database ID issue.


I am trying to use 'save as template' from site-collect2 and can get STP file but how do I assocaite this STP file to site-collect1. I am looking for any STSADM commands or source code that does this. Here also I wanted to create site-template with 'data' but it is giving me error. I will check this later. 

thanks for reading.please suggest.

add string in existing resource file


hi there
i need to add a string in a existing resource file
i am trying this but does not work
do you know the problem?

Private Function AddString(ByVal file As String, ByVal result As String)
        Dim language As Google.API.Language = Google.API.Language.English

        Dim resxFilePath As String = file '"c:\files"  

        Using rr As New ResXResourceReader(resxFilePath)
            Dim outputFilePath As String = resxFilePath.Replace(".vb", "") & ".resx"

            Using rw As New ResXResourceWriter(outputFilePath)

                rw.AddResource(result, Replace(result, Chr(34), ""))


            End Using
        End Using

    End Function

savefiledialog and openfiledialog: Selecting existing file or creating a new one


In my application (C#) users need to select existing file or create new file where they want to save some data. Existing files are in read-only mode because they are under Perforce subversion source control. I'm going to handle file checkout in my application automatically after user has selected the file where he wants to save data (or if file is new file, application adds it to source control).

The problem is that I can't use savefiledialog, because it complains about selected file being read-only. I could use openfiledialog, but it has couple problems. First problem is that openfiledialog confirm button has text "Open", which is something i could live with even though it would be better if it read "Save" :)

Second and bigger problem is when you want to create new file in openfiledialog. I set CheckFileExists to false so when user writes file name and presses "Open"-button, openfiledialog doesn't complain about file because it doesn't exist and it returns path to "new" file just fine. But problem is that if user has clicked or selected to some folder in openfiledialog and then writes file name and presses "Open"-button, openfiledialog just opens selected folder.

So basically I just need some file browsing dialog which works like savefiledialog but doesn't complain about read-only, i just need to

How to include page.xaml file in existing .net 2.0 project


We have a existing web based project in Asp.net and would like to use third party silver light control in the same application.

We need a help how to include silverlight control and use .xaml to access.

Please help




Removing blank line from a text file


Hi i have a comma deliminated text file which i am using to generate a multidimensional array using the following code:

Dim DefinitiveDatabase As String(,)
    Dim strfilename As String = (Server.MapPath("~\Definitive database.txt"))
    Dim num_rows As Long
    Dim num_cols As Long
    Dim x As Integer
    Dim y As Integer
    Dim value As Integer
    Dim ConditionName As String
    Dim strlines() As String
    Dim strline() As String
    Dim tmpstream As StreamReader = File.OpenText(strfilename)

strlines = tmpstream.ReadToEnd().Split(Environment.NewLine)
        num_rows = UBound(strlines)
        strline = strlines(0).Split(",")
        num_cols = UBound(strline)
        ReDim DefinitiveDatabase(num_rows, num_cols)
        For x = 0 To num_rows
            strline = strlines(x).Split(",")
            For y = 0 To num_col

How to write data into an existing PDF file


HI All,

I Have an existing pdf file with some editable fields like text boxes and text boxes, where i can enter data manually and save the file,

but i want to fill/paint data to these fields programmatically in vb.net, kindly share your thoughts..

How to check for existing node while writing in XML file ?



         I have to add a node each time the compiler passes through the following code :

         string XMLFilePath = System.Web.Hosting.HostingEnvironment.MapPath("~/Log/log.xml").ToString();

            if (File.Exists(XMLFilePath))
                XmlTextWriter xmlWriter = new XmlTextWriter(XMLFilePath, System.Text.Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                xmlWriter.WriteElementString("error", "No file input");

How to create a asmx file for an existing project?


Hello all,

I am very much a beginner to ASP.NET and I received a library of files. Most of them are .cs files but there are also two .dll files and a .pdb file in the bin folder.

Unfortunately, the package did not come with a asmx file, or any kind of file that I can upload to my website and run. It came with a csproj file in the main directory, but I have been unable to figure out how to create an asmx file with it.

The script came from here: http://www.psnapi.com.ar/downloads.aspx

They have a free trial version that only includes the .dll and .pdb file I mentioned. I have bought the full version as I need this for my website scripts. However, I am at the end of my rope because I can't for the life of me figure out how to get this working - even though it says it is web ready. I've contacted the author, but have yet to receive a reply in the past couple of days.

Any help, or where to start, would be most appreciated.



File Splitter in .Net

I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net Basics on File operations

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

SmtpClient and Locked File Attachments

Got a note a couple of days ago from a client using one of my generic routines that wraps SmtpClient. Apparently whenever a file has been attached to a message and emailed with SmtpClient the file remains locked after the message has been sent. Oddly this particular issue hasn't cropped up before for me although these routines are in use in a number of applications I've built.

How to call an .exe file in .net

Sometimes a developer has to call an EXE from another EXE. While calling EXE there can be a requirement to pass parameter.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend