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

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

Get Date Created info for file before uploading?

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

I have a FileUpload control on my page. I would like to get hold of the "date created" information of the file before it is uploaded. (Obviously, when you upload the file, the uploaded/copied version has a new "date created", set to the time of when you actually uploaded the file. This is not what I want!)

Does anyone please have any suggestions?

View Complete Post

More Related Resource Links

file creation date after uploading document to document library


Hi i am writing a event receiver to get the file creation date after the document is uploaded to the document library.

When a document library is uploaded to a document library the created date is overwriten by the uploaded date.


issues 1) i am not getting the folder path to get the filecreation date for system.io.file.getcreation() method

  public override void ItemAdded(SPItemEventProperties properties)

        properties.ListItem["Created"] =CreationTime(date);
        properties.ListItem["Title"] = itemurl;
      catch (Exception ex)


public CreationTime(SPItemEventProperties properties) {

 using (SPSite site = new SPSite("http://test"))

        SPWeb oWebsiteSrc = site.OpenWeb();

        SPFileCollection fileCollection = oWebsiteSrc.Files ;
        //get the filelocation of the current document library
        string filepath = fileCollection.Web.Lists["test"].Folders.ToString();
        SPList oList = site.AllWebs["jtest"].Lists["test"];
        SPFolder folder=oWebsiteSrc.Files.Folder;

        SPListItem fileitems =oWebsiteSrc.Lists["test"].Items[0] ;

Need to get actual created and modified time of the document while uploading file


    When I am uploading document to a document library, Normally  Create and Modified columns filled by today's date and time. But I need to fill those columns by actual created and modified date of that document, how can I do it.

I tried in this way,

I created a event receiver on ItemAdding and got file information, but I am unable to get the actual path from where file uplodaing ( so that I can have created and modified date).


SPFile spf = properties.ListItem.File;


string url = properties.AfterUrl;

All I need to get the file information (path, created and modified date) before it get uploaded to the document library.

AsyncFileUpload is not uploading the file



I have added AsyncFileUpload to creata user wizard control. When I tried to upload the file this control seemed to work fine and show confirmation at the end. But when I checked the website no file has been uploaded at all.

Here is the code, please let me know why its not uploading the files/images

<asp:ToolkitScriptManager ID="ScriptManager1" runat="server"></asp:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"  
 FinishDestinationPageUrl="~/MyPage.aspx"                                     LoginCreatedUser="False" CreateUserButtonText="Add" oncreateduser="CreateUserWizard1_CreatedUser1" 
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server" >
<asp:WizardStep ID="WizardStep1" runat="server" Title="Set preferences">
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" ThrobberID="spanUploading" OnClientUploadError="

file upload in Create User Wizard Created User event with UpdatePanel Tag wont work?



In my Create User Wizard1 Created User Wizard Event, I am collecting extra information from text boxes and allowing

the user to uplad a file.



I have put the Submit button within an Update Panel Tag but since I have done this it does not work.

Is there a way round it. In this situation would you use a trigger.?


<br />

  <asp:UpdatePanel ID="UpdatePanel2" runat="server">

  <asp:Button ID="StepNextButton" runat="server"  CommandName="MoveNext"  align="middle"
                                            Text="Submit my Profile" />

Uploading to SQL Server using AJAX muiltiple file uploader and dynamic SQL Server Tables


I am getting an error on the following code when trying to pload files directly to a database.  

 Incorrect syntax near ','.

 Incorrect syntax near 'image'.


    Private Sub Uploader_FileUploaded(ByVal sender As Object, ByVal args As UploaderEventArgs)

        Dim data() As Byte = New Byte((args.FileSize) - 1) {}

        Dim stream As Stream = args.OpenStream

        stream.Read(data, 0, data.Length)

    End Sub


Private Sub ButtonTellme_Click(ByVal sender As Object, ByVal e As EventArgs)


        Dim objConn As New SqlConnection("Data Source=mrpoteat.db.2798093.hostedresource.com; Initial Catalog=mrpoteat; User ID=mrpoteat; Password=Colgate23;")


        Dim strCommandText As String = ""

        For index = 1 To Attachments1.Items.Count Step 1

            strCommandText += "pic" + index.ToString() + Space(5)

File Attachments from info-path forms to Sharepoint document library


Hi Experts,

How to upload file attachements from info-path forms to Sharepoint document library?

I need to add attachement from local-PC/Any User to Sharepoint Document Library.


Any help please?? Appreciated




Document Library - Created by Info ?

How to know who created Document Library ? On my site, I have a group of 10 people with design/full control permissions and not sure who created 3 new document libraries. I was looking for this information in the browser as well as SPD, but no luck.

Access to path xxx denied when uploading a file using c#

Hi I have a file upload app written in c#. The app runs on IIS on a Windows 2003 Server OS. I want the app to upload the file onto the server (The app and the server are on the same machine). This code has been working fine for a long time running on Windows Server 2000, and Windows XP Professional. Now when I moved onto Windows Server 2003, it stopped working. I have given ASPNET account full access to the folder on the server, and it still gives this error. Is this a bug in 2003, and can anybody assist me? Thanks Shane

Uploading a file to a document library produces access denied error, but only on first try.

Hi I have a task which uses a custom form which is part of a custom workflow.  The form incorporates an asp fileUpload control to allow a user to browse for a local file which they can then select and it will be upload a file to a folder in a document library.  The first time this action is performed the folder in the document library will not exist so the code creates a folder and then uploads the file to it. The problem I have is, the first time users try and upload a file the directory is created in the document library as expected, but then the user gets redirected to the standard SharePoint Access Denied page.  If the user goes back to the task list, then loads the task web page again, selects the same file and hits upload, then the file is uploaded fine. All subsequent file uploads work fine after that for all users. Users have Contribute permissions on the document library. The code to do the upload is as follows.  The task has a "CR Number" associated with it, which the directory in the doc library should be called.  It uploads the file to a stream.  Then gets the url of the web and works out the file url and uploads it.  The creation and checking of the folder in the doc library happens in the getDirUrl method. /// <summary> /// Processes an uploaded file. /// </summary> /// <param name="

Uploading Large File (40mb) fails... (webhttpbinding) (Azure)

I'm using javascript to upload a file to my WCF service hosted on Azure.  (40 mb file) Here is the snippets from the web.config for the service: <system.serviceModel> <bindings> <webHttpBinding> <binding transferMode="Streamed" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" openTimeout="00:25:00" closeTimeout="00:25:00" sendTimeout="00:25:00" receiveTimeout="00:25:00" name="WebConfiguration"> </binding> </webHttpBinding> </bindings> <behaviors> <endpointBehaviors> <behavior name="RestfulEndpointBehavior"> <webHttp/> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="CPUploadServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpGetUrl=""/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <services> <service name="CPUpload" behaviorConfiguration="CPUploadServiceBehavior"> <endpoint add

Should time date stamp on .Asmx file change when project is rebuilt?

I have a web service project. The web service is named Recalc.asmx and it has a code behind file namedRecalc.asmx.vb Now if I make a change to my web service .vb code and then recompile the project, should my Recalc.asmx filebe updated as well? In windows explorer I see that the time date stamp of my Racalc.asmx.vb file changes to the date of the last change.But the time date stamp of the Recalc.asmx file does not change? Why is that? My original thinking was that I would simply need to copy the Recalc.asmx file to the test server. But the date stillshows it's original creation date of 7/1/2010 and not the date of the last rebuild as I was hoping it would do?

snp file retains format of default printer from which it was created

This seems to be the case: MS Access 2000/2003 generates a snp report via VBA (Windows 2000/XP is the general environment for the enterprise).  The report is emailed to another individual.  When the recipient tries to print the report the print options apparently force the print job into the printer's override tray as "Print to Heavy Paper"; thereby causing the printer to wait for a user to place paper into the override tray (the printer is in use by a number of users). This anomaly does not happen with snp reports sent from other users, only from the two who are using one particular printer as their default printer.  As this relates to a remote customer, I have not so far requested the [affecting] sender users try using a different printer.  Either way it causes someone to perform extra steps -- Sender: if the printer selection was to be changed each time a snp report is created; Recipient: each time they need to print the particular report they need to go into printer options and override the Heavy Paper issue by selecting letter paper (and always be alert that the particular report came from the two particular sender users -- whereas once the recipient user sends the print job, it's too late; they need to run over to the printer to insert paper into the override tray to avoid a backlog of printer jobs). The site's IS team has bee

Problem with uploading a zip file containing xls with macros

I am getting the following error when I try to upload a zip file containing xls file with macros. The zip file size is 4 mb. However, we have SP 2010 environment (ready to be deployed in couple of months) and it works there. So, it is not to do with the file. I am not sure if SP 2007 has any limitations/restrictions with .xlsm files. How do I fix this issue ? "GILA_Reports_File_byGTStar_9_2010.zip" contains the following virus: "Large uncompressed size; Tagged ID: C57E7332_69BC_484A_B087_DB04D574CDC4" . This file cannot be saved to the document library. If you want to save this file to the document library, clean the file using alternative virus scanning software and try saving it again.

user.identity.name="0" when uploading file using ajaxToolkit:AsyncFileUpload

hi, i am using AsyncFileupload to upload user picture. after the picture is uploaded and saved i opened another page and i noticed that the user.identity.name is lost. any idea 

delete a csv file created via StreamWriter?

I don't know if this is the correct forum.. but, is there a way I can automatically delete the following .csv file that was created via streamwriter (after it is viewed by an individual)?CODE (I would like to automatically delete the_filename.csv)://///////////////////////////////////////////////////////////////////////////////////////////////            string filename = "~/downloadfiles/data_complex987654321_filename.csv";             StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));             StringBuilder sb = new StringBuilder();            string filename = "~/the_filename.csv";            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));            StringBuilder sb = new StringBuilder();

Dynamic list item title based on date created & regional settings?

I have a list of things that doesn't *need* a title.  However, because sharepoint uses Title for links, RSS etc  I tried generating a title in an event handler.   This would work great if I wasn't basing it on a date field: public override void ItemAdding(SPItemEventProperties properties) { DateTime dt = Convert.ToDateTime(properties.AfterProperties["TestDate"]); properties.AfterProperties["Title"] = dt.ToShortDateString(); base.ItemAdding(properties); } In testing, this sets the title to "8/9/2010" when I selected 8/10/2010 in the date picker.  I figure this is because of the regional settings of my test user.  I can probably correct the title value for 'test user' but that won't fix 'test user in mongolia' who would still see two different values. So What I would like is to have the Title always display the value MyDate in the uesr's locale.  So the field needs to be dynamic not only at edit/update time, but at display time. Does anybody know if this can be accomplished, and more specifically how?

How to redirect bad date(xxx,9999) in datereceived column in text file in ssis

I want to redirect bad date format from flate file source to log table. I tried with redirect row but it is not working. Thanks in advance
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