|
Interesting...
I just created a 'Standard User' account and tested the test code .exe under that account and it failed!
Even the exception wasn't caught! Just a Win7 dialog, un-collapsing the details panel shows
Problem Event Name: CLR20r3
Problem Signature 01: consoleapplication.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 4b89d18d
Problem Signature 04: mscorlib
Problem Signature 05: 2.0.0.0
Problem Signature 06: 4a275af7
Problem Signature 07: 344b
Problem Signature 08: 15a
Problem Signature 09: System.UnauthorizedAccess
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 2057
I'll invesigate this more tomorrow
|
|
|
|
|
thanks again. And a nice cliff hanger. 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.
|
|
|
|
|
Couldn't go to bed with that on my mind!
The problem is I left the file in the 'CommonApplicationData' folder (X:\ProgramData\Test.txt) from when I ran under the admin account. The Standard User account could not overwrite it as it was created by a user from the Administrators group.
I deleted it using the admin account, switched to the Standard User, it ran perfectly and could overwrite the file it created itself with no issues on multiple runs.
|
|
|
|
|
More curious...
The file created by the Standard User can't be overwritten by the user from the 'Administrators' group either.
System.UnauthorizedAccessException:
Access to the path 'X:\ProgramData\Test.txt' is denied.
|
|
|
|
|
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
|
|
|
|
|