Outlook directoty

Y

Yael

Hi,
I need to get into my C# com add-in code the user outlook directory..
(where save a new directory on a computer: File-->manage data files-->open
folder)
C:\Documents and Settings\Owner\Local Settings\Application
Data\Microsoft\Outlook

there I want to open/create a txt file.
So, How to get this path from vs.net 2003?
Thank you!,
Yael.
 
K

Ken Slovak - [MVP - Outlook]

\Local Settings\Application Data is stored in the registry, that's usually
how I get that location.

It's stored at HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders\Local AppData.
 
Y

Yael

Thank's!
How in the C# code add-in I get this???
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders\Local AppData.
 
K

Ken Slovak - [MVP - Outlook]

Look up the Help on the Registry class. For Framework 1.1 you'd have to use
Registry.CurrentUser to get a RegistryKey object for that branch of the
registry and then use Subkeys. Framework 1.1 doesn't have the GetValue
method of Framework 2.0, which is much simpler to work with.
 
K

Ken Slovak - [MVP - Outlook]

That sample has nothing to do with reading the registry.

I have no sample code for framework 1.0 or 1.1 for reading the registry. You
will have to search using Google to find something for that. I provided the
class and property name you want to work with, you have to find samples for
that and also look at the MSDN documentation on the Registry class and what
it offers for the framework version you plan to use.
 
Y

Yael

Finally I found what I wanted!!!
I'm sorry if I didn't was clearly (my english is not the best :))

My goal was to get this path:

C:\Documents and Settings\Owner\Local Settings\Application
Data\Microsoft\Outlook
============ Start Code ============================

And there I put a txt file and read/write this txt file from my com add-in.
but I'm getting an error for access to this file..maybe I neet to set
shering or someting?
I was changed Outlook folder to not be read only, but I still get no access
to my txt file

C:\Documents and Settings\Owner\Local Settings\Application
Data\Microsoft\Outlook\myFile.txt

string textFilePath = System.Environment.GetFolderPath
(System.Environment.SpecialFolder.LocalApplicationData) +\\Microsoft\\Outlook;

============ End Code =============================
 
K

Ken Slovak - [MVP - Outlook]

Did you make a typo when you didn't use quotes around the last part of the
path?

It really should be:

string textFilePath = System.Environment.GetFolderPath
(System.Environment.SpecialFolder.LocalApplicationData) +
"\\Microsoft\\Outlook";

I tested using a StreamReader to read lines from a dummy text file I put in
that file path and I was able to read the text file with no problems.
 
Y

Yael

I fiext it..I forgote to add this path my txt file name:
string filepath = System.Environment.GetFolderPath
(System.Environment.SpecialFolder.LocalApplicationData)
+"\\Microsoft\\Outlook";
StreamReader sr = new StreamReader(filepath + "\\MatarotData.txt");

LOL :)
 

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