Open file fail: share voilation 
Author Message
 Open file fail: share voilation

Greetings,

I have an application that open a file and do something on it. But I find
that if in Windows Explore, the selection is on the file, then in my
application I can not open the file then, the error is "share voilation".

But I want that: in Windows Explore, right click on the file, then sendto My
Applicatioin. For the restriction, I can not archive that. There must be a
way to solve this problem. Because a lot of software like UltraEdit can do
so. But I don't know how to. Please help me!

Thanks in advance!
Evan



Sat, 03 Sep 2005 06:16:58 GMT  
 Open file fail: share voilation
What version of windows you are using? How did you Open the file?

Show me some code and steps to repro the issue? Thanks,
--------------------

::Subject: Open file fail: share voilation
::Date: Tue, 18 Mar 2003 13:16:58 +0800
::Lines: 16
::X-Priority: 3
::X-MSMail-Priority: Normal
::X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
::X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

::Newsgroups: microsoft.public.vc.mfc
::NNTP-Posting-Host: 175.33.252.135.in-addr.arpa 135.252.33.175
::Path: cpmsftngxa06!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
::Xref: cpmsftngxa06 microsoft.public.vc.mfc:368050
::X-Tomcat-NG: microsoft.public.vc.mfc
::
::Greetings,
::
::I have an application that open a file and do something on it. But I find
::that if in Windows Explore, the selection is on the file, then in my
::application I can not open the file then, the error is "share voilation".
::
::But I want that: in Windows Explore, right click on the file, then sendto
My
::Applicatioin. For the restriction, I can not archive that. There must be a
::way to solve this problem. Because a lot of software like UltraEdit can do
::so. But I don't know how to. Please help me!
::
::Thanks in advance!
::Evan
::
::
::
::

This posting is provided "AS IS" with no warranties, and confers no rights.



Sat, 03 Sep 2005 14:13:13 GMT  
 Open file fail: share voilation
Justin,

Thanks for your response!

I use Win2K. Following is the code, could you please figure out what's wrong
in the code. Thanks agian!

Evan

//========================================
  CFile file;
  CFileException e;
  if (!file.Open(strCurrentFile,
                 CFile::typeBinary |
                 CFile::modeReadWrite,
                 &e))
  {
   char buf[2048];
   char err[1024];
   e.GetErrorMessage(err, 1024);
   sprintf(buf, "Open file fail.\n%s", err);
   this->MessageBox(buf);
   return;
  }
//=========================================

Quote:
> What version of windows you are using? How did you Open the file?

> Show me some code and steps to repro the issue? Thanks,



Sun, 04 Sep 2005 01:55:48 GMT  
 Open file fail: share voilation
Use CFile::shareDenyNone

    Rail
--
        Recording Engineer/Software Developer
        Rail Jon Rogut Software
        http://home.earthlink.net/~railro


Quote:
> Justin,

> Thanks for your response!

> I use Win2K. Following is the code, could you please figure out what's
wrong
> in the code. Thanks agian!

> Evan

> //========================================
>   CFile file;
>   CFileException e;
>   if (!file.Open(strCurrentFile,
>                  CFile::typeBinary |
>                  CFile::modeReadWrite,
>                  &e))
>   {
>    char buf[2048];
>    char err[1024];
>    e.GetErrorMessage(err, 1024);
>    sprintf(buf, "Open file fail.\n%s", err);
>    this->MessageBox(buf);
>    return;
>   }
> //=========================================

> > What version of windows you are using? How did you Open the file?

> > Show me some code and steps to repro the issue? Thanks,



Sun, 04 Sep 2005 02:37:12 GMT  
 Open file fail: share voilation
Just tried. But didn't work.


Quote:
> Use CFile::shareDenyNone

>     Rail



Sun, 04 Sep 2005 03:02:45 GMT  
 Open file fail: share voilation
Hi Evan,

Just now, I use your code to repro the issue on my Win2k server but failed.
It worked fine.

--------------------




::Subject: Re: Open file fail: share voilation
::Date: Wed, 19 Mar 2003 10:02:45 +0800
::Lines: 11
::X-Priority: 3
::X-MSMail-Priority: Normal
::X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
::X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

::Newsgroups: microsoft.public.vc.mfc
::NNTP-Posting-Host: 175.33.252.135.in-addr.arpa 135.252.33.175
::Path:
cpmsftngxa08.phx.gbl!cppssbbsa01.microsoft.com!news-out.cwix.com!newsfeed.cw
ix.com!nntp.abs.net!uunet!dca.uu.net!logbridge.uoregon.edu!arclight.uoregon.
edu!enews.sgi.com!msrnewsc1!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
::Xref: cpmsftngxa08.phx.gbl microsoft.public.vc.mfc:366194
::X-Tomcat-NG: microsoft.public.vc.mfc
::
::Just tried. But didn't work.
::
::

::
::> Use CFile::shareDenyNone
::>
::>     Rail
::
::
::
::

This posting is provided "AS IS" with no warranties, and confers no rights.



Mon, 05 Sep 2005 15:13:38 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. how do I open a shared file

2. File.Open sharing question

3. Open file sharing issue

4. Too Many Files Open Error During Shared Memory Attach

5. sharing violation exception when using FIle Open menu option

6. open file with shared access.

7. Control sharing for files opened in a std::ofstream object

8. [ How I open a file shared by processes]

9. Opening Shared Files

10. how to open a file without sharing it?

11. Apply sharing violation without opening file

12. Double-Click to open data file failed

 

 
Powered by phpBB® Forum Software