ReadOnly without asking

K

Kim

Hi All

I want to Mark my word document writen by my C# .NET app. readonly without
asking about its then opening it again. No one have to change the contend of
document, only My app. must write this document.

I know the ReadOnlyRecommended object in Word "AsSave.

I work in VS2005 and use Office 2003

Best Regard
Kim s.
 
P

Peter Duniho

I want to Mark my word document writen by my C# .NET app. readonly
without
asking about its then opening it again. No one have to change the
contend of
document, only My app. must write this document.

I know the ReadOnlyRecommended object in Word "AsSave.

See File.SetAttributes().
 
C

christery

dirty workarount in C would be system("attrib +r c:\myfile.doc"); but
that too simple...
//CY
 
C

christery

True.

But using something from Microsoft.VisualBasic namespace
when there are equivalent functionality in System.IO is
not good C#.

Arne

Right U are

so my copying from manuals skills are not soo good... still the idea
is valid... I shuld be sleeping at 02:41 anyway...

A whole other thing just to flame:

but why not use system("cls") (C lingo) for cleaning a console when
printing chr 12 (form feed) stopped working going from my old
commodore VIC20 to C I still cant figure it out.

//CY
 
C

christery

Still dont see it...

[C#]
FileAttributes attr = FileAttributes.System | FileAttributes.Hidden |
FileAttributes.ReadOnly;
File.SetAttributes("slask.txt", attr);

[Visual Basic]
Dim attr as FileAttributes = FileAttributes.System or
FileAttributes.Hidden or FileAttributes.ReadOnly
File.SetAttributes("slask.txt", attr)

another approach...

file: system, hidden an readonly

why dont they not just google, to annoy Arne?

//CY
 
K

Kim

Hej Christery
I.m working in Word namespace not in file system. I have try to use SaveAs
and stil get the questen box then I open the word document, but I will try to
convert to PDF so the user not have to answer some thing. so I get a document
that only can be writen by my application

Best Regard
Kim s.
 
C

christery

Hej Christery
I.m working in Word namespace not in file system. I have try to use SaveAs
and stil get the questen box then I open the word document, but I will try to
convert to PDF so the user not have to answer some thing. so I get a document
that only can be writen by my application

Best Regard
Kim s.

So the problem arises when a user tries to open a readonly doc in
Microsoft Word that you have marked read only? did I get it right?
then i missunderstood you completly the firs time.

//CY
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top