|
yeah, I would expect:
1. AppData to be individual and hence writable and readable for the user account;
2. CommonAppData to be common to everyone, hence readable by everyone, but writable only by someone who can install the app.
Haven't seen it documented in any detail however.
BTW: if number 2 is what MS intended, CommonAppData does not make much sense, the folder holding the EXE would offer the same characteristics.
[EDIT] Well, it does keep settings apart from distributed code, so app settings would have a better chance of surviving an app upgrade[/EDIT]
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
 All users get read and execute permissions on folders/files created there - but not write/modify.
It can be altered of course by creating a folder for your app and setting permissions at that time.
Modified code below works so all users have Write and Modify as well so the store can be truly shared.
I'll clean up the code and put it into a reusable class and post as a Tip/Trick tomorrow.
using System;
using System.IO;
using System.Security.AccessControl;
namespace ConsoleApplication
{
class Program
{
public static readonly string UserPath =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
public static readonly string AllUsersPath =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
static void Main(string[] args)
{
try
{
string folderName = "Test";
string fileName = "Test.txt";
string textToSave = "AbcDefGhi";
string userDirectory = Path.Combine(UserPath, folderName);
string allUsersDirectory = Path.Combine(AllUsersPath, folderName);
string userFilePath = Path.Combine(userDirectory, fileName);
string allUsersFilePath = Path.Combine(allUsersDirectory, fileName);
CreateDirectoryWithPermissions(userDirectory);
CreateDirectoryWithPermissions(allUsersDirectory);
using (TextWriter userTextWriter = new StreamWriter(userFilePath),
allUsersTextWriter = new StreamWriter(allUsersFilePath))
{
Console.WriteLine("Writing {0} to {1}", textToSave, userFilePath);
userTextWriter.WriteLine(textToSave);
Console.WriteLine("Writing {0} to {1}", textToSave, allUsersFilePath);
allUsersTextWriter.WriteLine(textToSave);
}
using (TextReader userTextReader = new StreamReader(userFilePath),
allUsersTextReader = new StreamReader(allUsersFilePath))
{
Console.WriteLine("Reading from {0}", userFilePath);
Console.WriteLine(userTextReader.ReadLine());
Console.WriteLine("Reading from {0}", allUsersFilePath);
Console.WriteLine(allUsersTextReader.ReadLine());
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Console.ReadKey();
}
private static void CreateDirectoryWithPermissions(string path)
{
if (!Directory.Exists(path))
{
bool modified = false;
DirectoryInfo directoryInfo = directoryInfo = Directory.CreateDirectory(path);
DirectorySecurity directorySecurity = directoryInfo.GetAccessControl();
AccessRule rule = new FileSystemAccessRule(
"Users",
FileSystemRights.Write |
FileSystemRights.ReadAndExecute |
FileSystemRights.Modify,
InheritanceFlags.ContainerInherit |
InheritanceFlags.ObjectInherit,
PropagationFlags.InheritOnly,
AccessControlType.Allow);
directorySecurity.ModifyAccessRule(AccessControlModification.Add, rule, out modified);
directoryInfo.SetAccessControl(directorySecurity);
}
}
}
}
|
|
|
|
|
|
if you ask for Exception.ToString() there is no need to remember inner exceptions at all...
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Didn't know that
|
|
|
|
|
|
Tip posted here[^] with an improved reusable version of the solution I posted earlier.
|
|
|
|
|
Hi,
Can anyone please tell me if you know about any good "version control software"? Working in a live project of C#. Since its improving 'everyday', need to save every version of projects with description, which have been delivered to the customer already.
Any idea?
|
|
|
|
|
Git[^] seems very popular.
I haven't used it though, so I can't tell how good it is. Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
I am using VisualSVNServer. with following plugins as clients
For visual studio, AnkhSVN works great.
For Files and Forders, TortoiseSVN works great.
|
|
|
|
|
Hi Som,
Thanks. i installed this software with plugins, but not finding any direct way to use it, bit confusing...
|
|
|
|
|
May be This[^] could be a right place to start
|
|
|
|
|
Hi Som,
Thanks a lot, This guide seems to be really helpful. Now I am sure i'll be able to manage it.
Regards. /Khan.
|
|
|
|
|
|
SourceGear Vault, www.sourcegear.com[^], is free for a single user license.Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hi, thanks. i looked at the demo on their site. Are you sure One user Licese is free? Didn't find it in License page.
Regards. /Khan.
|
|
|
|
|
khanolid wrote: One user Licese is free
Yes, absolutely sure. "and Vault is always free for single users" http://www.sourcegear.com/vault/[^]Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
I used to use subversion (I used TortoiseSVN), but recently switched to Mercurial distributed version control software. There have been a few threads about it here in the lounge this past week. On windows, I am using TortoiseHg and on Linux, I am just using the command line. I am liking it very much.
|
|
|
|
|
Well, there are hundreds out there. If you are coming from a background of something like SourceSafe, then Subversion will come as a bit of a shock, because it has a very different approach to source control, but it's good once you get into its mindset. SourceGear's Vault is sort of "SourceSafe on steroids", GIT is very fashionable at the moment but I've never seen the appeal; same thing with Bazaar which is popular with some people (Pythonistas, mainly). MKS do some good products, but they are top-end and relatively expensive. There's also a freebie opensource Java one called SourceJammer which is probably OK for entry-level Java shops. Those are the ones I've had experience with (to varying degrees).
One link that you might find useful:
http://en.wikipedia.org/wiki/Comparison_of_revision_control_software[^]
|
|
|
|
|
application Getting Crashed if i run the below code....
class Program
{
static void Main(string[] args)
{
try
{
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object file = "D\\two.doc";
object readOnly = false;
object isVisible = true;
object o_null = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file,
ref o_null, ref o_null, ref o_null, ref o_null, ref o_null,
ref o_null, ref o_null, ref o_null, ref o_null, ref o_null,
ref o_null, ref o_null, ref o_null, ref o_null, ref o_null);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
string allText = data.GetData(DataFormats.Text).ToString();
//doc.Close(ref missing, ref missing, ref missing);
//wordApp.Quit(ref missing, ref missing, ref missing);
Console.WriteLine(allText);
}
catch(Exception e)
{
Console.Write(e);
}
}
}
can some body help me out and suggest me the actual problem or else correct it.
Thanks in advance....
|
|
|
|
|
First of all, please wrap your source code in PRE tags to make it easier to read.
Anyway, it seems like you're missing a colon here:
object file = "D\\two.doc";
It should be:
object file = "D:\\two.doc";
(I might be wrong, but that's the only explanation I can come up with) Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
Hello friends!
How to clear a text file from my code?
I write on C #.
|
|
|
|
|
an existing file can be:
- deleted with File.Delete(path)
- replaced by an empty file with File.WriteAllText(path, "")
provided the file isn't open and access rights allow you to do those things.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Here are two ways you can do that:
File.WriteAllText(@"C:\mytextfile.txt", string.Empty);
((new FileInfo(@"C:\mytextfile.txt")).Open(FileMode.Truncate)).Close();
If you meant you want to delete a file, you can do this:
File.Delete(@"C:\mytextfile.txt");
|
|
|
|
|
See here[^]. This link give you an idea on how to do basic IO operations on a text file. You can open a file and clear its contents using these IO functions.Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|