473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Data file only opened by 1 app.

Hi

In an app that I', writing, I would like to implement the similar to the
functionality in MS Word where Word detects wether a *.doc file has already
been opened in another instance of Word. I guess I would set some file
attribute like read-only or something on the file - however, does anyone know
of any other smart way to secure that a the same data file is only opened in
one instance of a program at a time.

Thanks.

Jesper.
May 28 '07 #1
2 1122
You should be able to open it exclusively whihc will rpevent anyone else
opening it

FileStream myStream = File.Open(FileName, FileMode.Open, FileAccess.Write,
FileShare.None);

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Jesper, Denmark" <Je***********@discussions.microsoft.comwrote in message
news:77**********************************@microsof t.com...
Hi

In an app that I', writing, I would like to implement the similar to the
functionality in MS Word where Word detects wether a *.doc file has
already
been opened in another instance of Word. I guess I would set some file
attribute like read-only or something on the file - however, does anyone
know
of any other smart way to secure that a the same data file is only opened
in
one instance of a program at a time.

Thanks.

Jesper.

May 28 '07 #2
"Jesper, Denmark" <Je***********@discussions.microsoft.comschrieb im
Newsbeitrag news:77**********************************@microsof t.com...
Hi

In an app that I', writing, I would like to implement the similar to the
functionality in MS Word where Word detects wether a *.doc file has
already
been opened in another instance of Word. I guess I would set some file
attribute like read-only or something on the file - however, does anyone
know
of any other smart way to secure that a the same data file is only opened
in
one instance of a program at a time.

Thanks.

Jesper.

Hi Jesper,

this depends on the "opening" application how it opens
the file. It can e.g. open the file with different FileShare-Modes.
Take a look at this:

[File.Open Method (String, FileMode, FileAccess, FileShare)]
http://msdn2.microsoft.com/en-us/library/y973b725.aspx

[FileShare Enumeration]
http://msdn2.microsoft.com/en-us/lib...fileshare.aspx

This should be a good guide,...
Best regards

Kerem Gümrükcü
May 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Julia Baresch | last post by:
Everyone, I posted the message below back in February and didn't get any information. I also wasn't able to find any documentation in MS Help, web site, or other groups. I'm posting now with...
7
by: Lian | last post by:
Hi every body I have a problem with accesses and visual studio. I've just installed XP and I can't get a connection with the Data base. I have this error and I don't know how to fix it The...
9
by: Sandy | last post by:
can mfc application, send text data to opened notepad file in desktop?(live transfer of data) . can anybody help
38
by: Tom | last post by:
I need my data generating C program on computer #1 to export small amounts of data (one - 40 byte data structure) periodically (once per minute) to a C program on computer #2. I am considering...
4
by: Petr Jakes | last post by:
I am trying to save data it is comming from the serial port continually for some period. (expect reading from serial port is 100% not a problem) Following is an example of the code I am trying to...
6
by: trl10 | last post by:
Hi Everyone, I'm still trying to learn C++ and this is my final project. We have to read sales data from a file into an array, process data in a partially filled array via functions, pass an array...
1
by: anithanet | last post by:
Hi this is anitha, I bind the opened excel file data to gridview using olebd providers it works fine in my local. when i configure that one in iis it rasies an error that The...
4
by: omono84 | last post by:
I know that this should be rather simple but i seem to be missing a step to get it to work. and have been unable to find a solution on the net. The aim is that I click on the open button to find...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.