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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Opening File that is already exclusively opened

Opening File that is already exclusively opened

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 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.
  • H Offline
    H Offline
    Harsh Shankar
    wrote on last edited by
    #1

    Hi Guys, As i was working i got a problem. as i have to open a file, i simply call CreateFile and it Opens it. now if some application like MS Excel ect have open it previously, it is not letting me open the file.. now if it is about sharing voilation, how notepad manages the file to open it?? i think i am clear to whar i require Expecting some Quick responce..

    HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

    C 1 Reply Last reply
    0
    • H Harsh Shankar

      Hi Guys, As i was working i got a problem. as i have to open a file, i simply call CreateFile and it Opens it. now if some application like MS Excel ect have open it previously, it is not letting me open the file.. now if it is about sharing voilation, how notepad manages the file to open it?? i think i am clear to whar i require Expecting some Quick responce..

      HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      My guess is that Notepad opens the file for reading only (and only tries to open it for writing if the user wants to save, at which point it will also fail), when Excel or Word or the likes opens the file it probably allows other processes to read the file, but not to write to them (this would explain how you get a "open for reading only" option from Word if you try to open a document that is opened by another word instance/another user's word...). Can it be that when you use CreateFile to open the file you try to open it for writing?

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

      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