After deleting file and re-creating file, not change creation date in windows











up vote
7
down vote

favorite
1












I have c# application. This write log in folder.



below code.



if (File.Exists(@"C:EXT_LOGLOG.txt"))
{
File.Delete(@"C:EXT_LOGLOG.txt");
}

string Data = "xxxxx";
System.IO.StreamWriter file = new StreamWriter(@"C:EXT_LOGLOG.txt");
file.WriteLine(Data);
file.Dispose();
file.Close();


I delete file, if it exist, and I create file with same name.
when I run program, the creation date of file is not change.



I guess windows any manager or any file table still contain that file.



So, when I delete file, can I delete manager or file table content??










share|improve this question






















  • How and when are you retrieving the creation date? If it's just Windows Explorer, have you tried hitting F5 to refresh the view?
    – Grant
    Oct 20 '15 at 2:52






  • 1




    @GrantWinney Actually you can test this yourself from Windows Explorer. 1) Find an existing old file. 2) delete it 3) Create a new file with the same name 4) New file will have the same Created as per old file (assuming you do it sufficient quickly). See dotnetkid's answer below. I was surprised myself :)
    – MickyD
    Oct 20 '15 at 3:26








  • 2




    The reason for this is to enable safe save. Like what MS WORD does. When application programs auto save, they do not over-write files. Instead, they move old file, and create a replica new file. However, the new file needs to retain the attributes of old file including creation time. Refer to temp files you see with ~ sign before them, enabling hidden files to see this happening.
    – SreekanthGS
    Oct 20 '15 at 5:15












  • @Micky That is surprising! Didn't expect that behavior.
    – Grant
    Oct 20 '15 at 11:06















up vote
7
down vote

favorite
1












I have c# application. This write log in folder.



below code.



if (File.Exists(@"C:EXT_LOGLOG.txt"))
{
File.Delete(@"C:EXT_LOGLOG.txt");
}

string Data = "xxxxx";
System.IO.StreamWriter file = new StreamWriter(@"C:EXT_LOGLOG.txt");
file.WriteLine(Data);
file.Dispose();
file.Close();


I delete file, if it exist, and I create file with same name.
when I run program, the creation date of file is not change.



I guess windows any manager or any file table still contain that file.



So, when I delete file, can I delete manager or file table content??










share|improve this question






















  • How and when are you retrieving the creation date? If it's just Windows Explorer, have you tried hitting F5 to refresh the view?
    – Grant
    Oct 20 '15 at 2:52






  • 1




    @GrantWinney Actually you can test this yourself from Windows Explorer. 1) Find an existing old file. 2) delete it 3) Create a new file with the same name 4) New file will have the same Created as per old file (assuming you do it sufficient quickly). See dotnetkid's answer below. I was surprised myself :)
    – MickyD
    Oct 20 '15 at 3:26








  • 2




    The reason for this is to enable safe save. Like what MS WORD does. When application programs auto save, they do not over-write files. Instead, they move old file, and create a replica new file. However, the new file needs to retain the attributes of old file including creation time. Refer to temp files you see with ~ sign before them, enabling hidden files to see this happening.
    – SreekanthGS
    Oct 20 '15 at 5:15












  • @Micky That is surprising! Didn't expect that behavior.
    – Grant
    Oct 20 '15 at 11:06













up vote
7
down vote

favorite
1









up vote
7
down vote

favorite
1






1





I have c# application. This write log in folder.



below code.



if (File.Exists(@"C:EXT_LOGLOG.txt"))
{
File.Delete(@"C:EXT_LOGLOG.txt");
}

string Data = "xxxxx";
System.IO.StreamWriter file = new StreamWriter(@"C:EXT_LOGLOG.txt");
file.WriteLine(Data);
file.Dispose();
file.Close();


I delete file, if it exist, and I create file with same name.
when I run program, the creation date of file is not change.



I guess windows any manager or any file table still contain that file.



So, when I delete file, can I delete manager or file table content??










share|improve this question













I have c# application. This write log in folder.



below code.



if (File.Exists(@"C:EXT_LOGLOG.txt"))
{
File.Delete(@"C:EXT_LOGLOG.txt");
}

string Data = "xxxxx";
System.IO.StreamWriter file = new StreamWriter(@"C:EXT_LOGLOG.txt");
file.WriteLine(Data);
file.Dispose();
file.Close();


I delete file, if it exist, and I create file with same name.
when I run program, the creation date of file is not change.



I guess windows any manager or any file table still contain that file.



So, when I delete file, can I delete manager or file table content??







c# file






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 20 '15 at 2:50









T.K S

362




362












  • How and when are you retrieving the creation date? If it's just Windows Explorer, have you tried hitting F5 to refresh the view?
    – Grant
    Oct 20 '15 at 2:52






  • 1




    @GrantWinney Actually you can test this yourself from Windows Explorer. 1) Find an existing old file. 2) delete it 3) Create a new file with the same name 4) New file will have the same Created as per old file (assuming you do it sufficient quickly). See dotnetkid's answer below. I was surprised myself :)
    – MickyD
    Oct 20 '15 at 3:26








  • 2




    The reason for this is to enable safe save. Like what MS WORD does. When application programs auto save, they do not over-write files. Instead, they move old file, and create a replica new file. However, the new file needs to retain the attributes of old file including creation time. Refer to temp files you see with ~ sign before them, enabling hidden files to see this happening.
    – SreekanthGS
    Oct 20 '15 at 5:15












  • @Micky That is surprising! Didn't expect that behavior.
    – Grant
    Oct 20 '15 at 11:06


















  • How and when are you retrieving the creation date? If it's just Windows Explorer, have you tried hitting F5 to refresh the view?
    – Grant
    Oct 20 '15 at 2:52






  • 1




    @GrantWinney Actually you can test this yourself from Windows Explorer. 1) Find an existing old file. 2) delete it 3) Create a new file with the same name 4) New file will have the same Created as per old file (assuming you do it sufficient quickly). See dotnetkid's answer below. I was surprised myself :)
    – MickyD
    Oct 20 '15 at 3:26








  • 2




    The reason for this is to enable safe save. Like what MS WORD does. When application programs auto save, they do not over-write files. Instead, they move old file, and create a replica new file. However, the new file needs to retain the attributes of old file including creation time. Refer to temp files you see with ~ sign before them, enabling hidden files to see this happening.
    – SreekanthGS
    Oct 20 '15 at 5:15












  • @Micky That is surprising! Didn't expect that behavior.
    – Grant
    Oct 20 '15 at 11:06
















How and when are you retrieving the creation date? If it's just Windows Explorer, have you tried hitting F5 to refresh the view?
– Grant
Oct 20 '15 at 2:52




How and when are you retrieving the creation date? If it's just Windows Explorer, have you tried hitting F5 to refresh the view?
– Grant
Oct 20 '15 at 2:52




1




1




@GrantWinney Actually you can test this yourself from Windows Explorer. 1) Find an existing old file. 2) delete it 3) Create a new file with the same name 4) New file will have the same Created as per old file (assuming you do it sufficient quickly). See dotnetkid's answer below. I was surprised myself :)
– MickyD
Oct 20 '15 at 3:26






@GrantWinney Actually you can test this yourself from Windows Explorer. 1) Find an existing old file. 2) delete it 3) Create a new file with the same name 4) New file will have the same Created as per old file (assuming you do it sufficient quickly). See dotnetkid's answer below. I was surprised myself :)
– MickyD
Oct 20 '15 at 3:26






2




2




The reason for this is to enable safe save. Like what MS WORD does. When application programs auto save, they do not over-write files. Instead, they move old file, and create a replica new file. However, the new file needs to retain the attributes of old file including creation time. Refer to temp files you see with ~ sign before them, enabling hidden files to see this happening.
– SreekanthGS
Oct 20 '15 at 5:15






The reason for this is to enable safe save. Like what MS WORD does. When application programs auto save, they do not over-write files. Instead, they move old file, and create a replica new file. However, the new file needs to retain the attributes of old file including creation time. Refer to temp files you see with ~ sign before them, enabling hidden files to see this happening.
– SreekanthGS
Oct 20 '15 at 5:15














@Micky That is surprising! Didn't expect that behavior.
– Grant
Oct 20 '15 at 11:06




@Micky That is surprising! Didn't expect that behavior.
– Grant
Oct 20 '15 at 11:06












2 Answers
2






active

oldest

votes

















up vote
5
down vote













That's how it works in windows. I have not searched Google for WHY. However it seems you can set the creation date of the file through C# using System.IO.File.SetCreationTime method.



public static void SetCreationTime(
string path,
DateTime creationTime
)


Source: https://msdn.microsoft.com/en-us/library/system.io.file.setcreationtime(v=vs.100).aspx






share|improve this answer

















  • 3




    As dotnetkid mentioned, this is the default windows behaviour. The reason for this behaviour can be found here: support.microsoft.com/en-us/kb/172190
    – Don
    Oct 20 '15 at 3:05


















up vote
0
down vote













this is how I solve the problem:



File.WriteAllBytes(outFile, body);

File.SetCreationTimeUtc(outFile, DateTime.UtcNow);





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33227149%2fafter-deleting-file-and-re-creating-file-not-change-creation-date-in-windows%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    5
    down vote













    That's how it works in windows. I have not searched Google for WHY. However it seems you can set the creation date of the file through C# using System.IO.File.SetCreationTime method.



    public static void SetCreationTime(
    string path,
    DateTime creationTime
    )


    Source: https://msdn.microsoft.com/en-us/library/system.io.file.setcreationtime(v=vs.100).aspx






    share|improve this answer

















    • 3




      As dotnetkid mentioned, this is the default windows behaviour. The reason for this behaviour can be found here: support.microsoft.com/en-us/kb/172190
      – Don
      Oct 20 '15 at 3:05















    up vote
    5
    down vote













    That's how it works in windows. I have not searched Google for WHY. However it seems you can set the creation date of the file through C# using System.IO.File.SetCreationTime method.



    public static void SetCreationTime(
    string path,
    DateTime creationTime
    )


    Source: https://msdn.microsoft.com/en-us/library/system.io.file.setcreationtime(v=vs.100).aspx






    share|improve this answer

















    • 3




      As dotnetkid mentioned, this is the default windows behaviour. The reason for this behaviour can be found here: support.microsoft.com/en-us/kb/172190
      – Don
      Oct 20 '15 at 3:05













    up vote
    5
    down vote










    up vote
    5
    down vote









    That's how it works in windows. I have not searched Google for WHY. However it seems you can set the creation date of the file through C# using System.IO.File.SetCreationTime method.



    public static void SetCreationTime(
    string path,
    DateTime creationTime
    )


    Source: https://msdn.microsoft.com/en-us/library/system.io.file.setcreationtime(v=vs.100).aspx






    share|improve this answer












    That's how it works in windows. I have not searched Google for WHY. However it seems you can set the creation date of the file through C# using System.IO.File.SetCreationTime method.



    public static void SetCreationTime(
    string path,
    DateTime creationTime
    )


    Source: https://msdn.microsoft.com/en-us/library/system.io.file.setcreationtime(v=vs.100).aspx







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 20 '15 at 2:58









    Nikhil Vartak

    3,65121623




    3,65121623








    • 3




      As dotnetkid mentioned, this is the default windows behaviour. The reason for this behaviour can be found here: support.microsoft.com/en-us/kb/172190
      – Don
      Oct 20 '15 at 3:05














    • 3




      As dotnetkid mentioned, this is the default windows behaviour. The reason for this behaviour can be found here: support.microsoft.com/en-us/kb/172190
      – Don
      Oct 20 '15 at 3:05








    3




    3




    As dotnetkid mentioned, this is the default windows behaviour. The reason for this behaviour can be found here: support.microsoft.com/en-us/kb/172190
    – Don
    Oct 20 '15 at 3:05




    As dotnetkid mentioned, this is the default windows behaviour. The reason for this behaviour can be found here: support.microsoft.com/en-us/kb/172190
    – Don
    Oct 20 '15 at 3:05












    up vote
    0
    down vote













    this is how I solve the problem:



    File.WriteAllBytes(outFile, body);

    File.SetCreationTimeUtc(outFile, DateTime.UtcNow);





    share|improve this answer



























      up vote
      0
      down vote













      this is how I solve the problem:



      File.WriteAllBytes(outFile, body);

      File.SetCreationTimeUtc(outFile, DateTime.UtcNow);





      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        this is how I solve the problem:



        File.WriteAllBytes(outFile, body);

        File.SetCreationTimeUtc(outFile, DateTime.UtcNow);





        share|improve this answer














        this is how I solve the problem:



        File.WriteAllBytes(outFile, body);

        File.SetCreationTimeUtc(outFile, DateTime.UtcNow);






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 17 hours ago









        Mohammad

        12.5k93158




        12.5k93158










        answered 18 hours ago









        Ivo Tabakov

        12




        12






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33227149%2fafter-deleting-file-and-re-creating-file-not-change-creation-date-in-windows%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen