Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. file create problem

file create problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    david bagaturia
    wrote on last edited by
    #1

    Hi all. result of this code is "cant create File" and I dont know why. can help?? wchar_t FileName[250]= L"C:\\File Manager Service Log\\log.txt"; wchar_t *pFileName = MySystemTime(FileName); HANDLE F; F=CreateFile((LPCTSTR)pFileName, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); if(F == INVALID_HANDLE_VALUE) { printf("cant create File"); getchar(); return; } :confused::confused::confused::confused::confused: :confused:

    P H 2 Replies Last reply
    0
    • D david bagaturia

      Hi all. result of this code is "cant create File" and I dont know why. can help?? wchar_t FileName[250]= L"C:\\File Manager Service Log\\log.txt"; wchar_t *pFileName = MySystemTime(FileName); HANDLE F; F=CreateFile((LPCTSTR)pFileName, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); if(F == INVALID_HANDLE_VALUE) { printf("cant create File"); getchar(); return; } :confused::confused::confused::confused::confused: :confused:

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      david bagaturia wrote:

      wchar_t *pFileName = MySystemTime(FileName); HANDLE F;

      Does pFileName conatins valid path here ? If yes, then there should not be any problem with file creation.Use GetLastError to narrow down the error.

      Prasad Notifier using ATL | Operator new[],delete[][^]

      A 1 Reply Last reply
      0
      • P prasad_som

        david bagaturia wrote:

        wchar_t *pFileName = MySystemTime(FileName); HANDLE F;

        Does pFileName conatins valid path here ? If yes, then there should not be any problem with file creation.Use GetLastError to narrow down the error.

        Prasad Notifier using ATL | Operator new[],delete[][^]

        A Offline
        A Offline
        apoorva_raje
        wrote on last edited by
        #3

        try calling GetShortPathName before the create file function..

        1 Reply Last reply
        0
        • D david bagaturia

          Hi all. result of this code is "cant create File" and I dont know why. can help?? wchar_t FileName[250]= L"C:\\File Manager Service Log\\log.txt"; wchar_t *pFileName = MySystemTime(FileName); HANDLE F; F=CreateFile((LPCTSTR)pFileName, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); if(F == INVALID_HANDLE_VALUE) { printf("cant create File"); getchar(); return; } :confused::confused::confused::confused::confused: :confused:

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          What happens if you run this code

          wchar_t FileName[250]= L"e:\\Test is ok\\log.txt";

          HANDLE F;

          F=CreateFileW(FileName,
          GENERIC_READ,
          FILE_SHARE_READ,
          NULL,
          CREATE_NEW,
          FILE_ATTRIBUTE_NORMAL,
          0);
          CloseHandle(F);


          WhiteSky


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups