Custom Files?

  • Thread starter Thread starter Flashster
  • Start date Start date
F

Flashster

My program writes text to a file. Currently the files have a suffix of
'.log' . I want to make sure that the user does not attempt to open a file
that was not originally created by my program.

I don't really want to write some code to the top of the text file that I'd
have to filter out each time I read it, so how else would I do it?

Would I perhaps:
i) create a custom file type with a custom suffix and get the system to
associate that suffix with my program (if so how??)
ii) set an attribute of the file (e.g. a "creator" attribute, if there is
one?) to my program name and check it prior to opening the file (again, if
so how??)
 
You can try these things...

Dim FileProperties As FileVersionInfo =
FileVersionInfo.GetVersionInfo("FilePath")
Msgbox(FileProperties.ProductVersion)

/Lars
 
Flashster said:
My program writes text to a file. Currently the files have a suffix of
'.log' . I want to make sure that the user does not attempt to open a file
that was not originally created by my program.

I don't really want to write some code to the top of the text file that I'd
have to filter out each time I read it, so how else would I do it?

Would I perhaps:
i) create a custom file type with a custom suffix and get the system to
associate that suffix with my program (if so how??)
ii) set an attribute of the file (e.g. a "creator" attribute, if there is
one?) to my program name and check it prior to opening the file (again, if
so how??)

Even if you made a custom file extension, someone could still open it in
notepad. So if you save the file in plan text, neither of your ideas
will suffice. To make sure nobody can read your file you will need to
encrypt it.

Chris
 
Flashster,
I would define a custom extension for you app. You can use a setup packed to
define the extension when you deploy the app.

To ensure that the file being read can be understood by my app, rather then
use plain text, I would use a "structured format", such as XML or Binary
Serialization.

This way when the program attempted to deserialize the document I would get
an exception if the document is not in the expected format...

As Chris suggests, encrypting the document can also be useful.

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| My program writes text to a file. Currently the files have a suffix of
| '.log' . I want to make sure that the user does not attempt to open a
file
| that was not originally created by my program.
|
| I don't really want to write some code to the top of the text file that
I'd
| have to filter out each time I read it, so how else would I do it?
|
| Would I perhaps:
| i) create a custom file type with a custom suffix and get the system to
| associate that suffix with my program (if so how??)
| ii) set an attribute of the file (e.g. a "creator" attribute, if there is
| one?) to my program name and check it prior to opening the file (again, if
| so how??)
|
|
|
 
Thanks. I'll look into the XML format I think. But regarding the custom file
extension: Do I need to apply to the relevent organisations to use a custom
file extension? In the Microsoft info below, it mentions submitting a
request to the IANA for the file type??

http://msdn.microsoft.com/library/d..._extending/fileassociations/fa_file_types.asp

This is only a small application which is being provided to a small number
of individuals in a single organisation, so surely I don't have to do
this....do I?
 
My take on that article is if you plan on having a Public File type, then
yes you should register it with the IANA, however if you are planning a
Private File Type, then I wouldn't worry about it.

Of course not registering it, may mean another app would start using it &
potentially cause problems for you.

I would also consider my target audience in deciding to register the type or
not.

I would also consider if the documents are going potentially to be placed on
web servers as hyper links...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Thanks. I'll look into the XML format I think. But regarding the custom
file
| extension: Do I need to apply to the relevent organisations to use a
custom
| file extension? In the Microsoft info below, it mentions submitting a
| request to the IANA for the file type??
|
|
http://msdn.microsoft.com/library/d..._extending/fileassociations/fa_file_types.asp
|
| This is only a small application which is being provided to a small number
| of individuals in a single organisation, so surely I don't have to do
| this....do I?
|
|
|
|
|
|
|
| message | > Flashster,
| > I would define a custom extension for you app. You can use a setup
packed
| > to
| > define the extension when you deploy the app.
| >
| > To ensure that the file being read can be understood by my app, rather
| > then
| > use plain text, I would use a "structured format", such as XML or Binary
| > Serialization.
| >
| > This way when the program attempted to deserialize the document I would
| > get
| > an exception if the document is not in the expected format...
| >
| > As Chris suggests, encrypting the document can also be useful.
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > .NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > | > | My program writes text to a file. Currently the files have a suffix of
| > | '.log' . I want to make sure that the user does not attempt to open a
| > file
| > | that was not originally created by my program.
| > |
| > | I don't really want to write some code to the top of the text file
that
| > I'd
| > | have to filter out each time I read it, so how else would I do it?
| > |
| > | Would I perhaps:
| > | i) create a custom file type with a custom suffix and get the system
to
| > | associate that suffix with my program (if so how??)
| > | ii) set an attribute of the file (e.g. a "creator" attribute, if there
| > is
| > | one?) to my program name and check it prior to opening the file
(again,
| > if
| > | so how??)
| > |
| > |
| > |
| >
| >
|
|
 
Thanks Jay. I'll use a fairly long file suffix so its less likely to clash
with anything and its only for a limited number of users anyway.

Jay B. Harlow said:
My take on that article is if you plan on having a Public File type, then
yes you should register it with the IANA, however if you are planning a
Private File Type, then I wouldn't worry about it.

Of course not registering it, may mean another app would start using it &
potentially cause problems for you.

I would also consider my target audience in deciding to register the type
or
not.

I would also consider if the documents are going potentially to be placed
on
web servers as hyper links...

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Thanks. I'll look into the XML format I think. But regarding the custom
file
| extension: Do I need to apply to the relevent organisations to use a
custom
| file extension? In the Microsoft info below, it mentions submitting a
| request to the IANA for the file type??
|
|
http://msdn.microsoft.com/library/d..._extending/fileassociations/fa_file_types.asp
|
| This is only a small application which is being provided to a small
number
| of individuals in a single organisation, so surely I don't have to do
| this....do I?
|
|
|
|
|
|
|
| message | > Flashster,
| > I would define a custom extension for you app. You can use a setup
packed
| > to
| > define the extension when you deploy the app.
| >
| > To ensure that the file being read can be understood by my app, rather
| > then
| > use plain text, I would use a "structured format", such as XML or
Binary
| > Serialization.
| >
| > This way when the program attempted to deserialize the document I
would
| > get
| > an exception if the document is not in the expected format...
| >
| > As Chris suggests, encrypting the document can also be useful.
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > .NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > | > | My program writes text to a file. Currently the files have a suffix
of
| > | '.log' . I want to make sure that the user does not attempt to open
a
| > file
| > | that was not originally created by my program.
| > |
| > | I don't really want to write some code to the top of the text file
that
| > I'd
| > | have to filter out each time I read it, so how else would I do it?
| > |
| > | Would I perhaps:
| > | i) create a custom file type with a custom suffix and get the system
to
| > | associate that suffix with my program (if so how??)
| > | ii) set an attribute of the file (e.g. a "creator" attribute, if
there
| > is
| > | one?) to my program name and check it prior to opening the file
(again,
| > if
| > | so how??)
| > |
| > |
| > |
| >
| >
|
|
 

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

Back
Top