Is the Broken Code Related to UAC Settings in AppData Folder?

  • Thread starter Thread starter CRGreathouse
  • Start date Start date
  • Tags Tags
    Broken Code
Click For Summary
SUMMARY

The discussion centers on a code issue related to file processing in a user's AppData folder, potentially influenced by User Account Control (UAC) settings in Windows Vista. The code snippet provided attempts to create a StreamWriter for an output file but fails to display the expected dialog after confirming the output filename is valid. The absence of the "sw setup" dialog indicates a possible silent failure during the StreamWriter initialization, likely due to UAC restrictions on file access in the AppData directory.

PREREQUISITES
  • Understanding of C# programming and exception handling
  • Familiarity with Windows Vista UAC settings and their impact on file access
  • Knowledge of file I/O operations in .NET, specifically using StreamWriter
  • Basic concepts of directory structure and user profile paths in Windows
NEXT STEPS
  • Investigate UAC settings and their effects on file permissions in Windows Vista
  • Learn about debugging techniques in C# to identify silent failures
  • Explore alternative methods for handling file access exceptions in .NET
  • Research best practices for managing user data in AppData folders
USEFUL FOR

Software developers, particularly those working with C# and Windows applications, as well as system administrators managing UAC settings and user permissions.

CRGreathouse
Science Advisor
Homework Helper
Messages
2,832
Reaction score
0
Broken code -- UAC related?

Here's the code I'm having trouble with, cut down the relevant part:

Code:
protected void ProcessFiles(string[] files)
{
	if (File.Exists(outputFilename))
		throw new Exception("Output file " + outputFilename + " already exists!");
	if (Directory.Exists(direc(outputFilename)))
		throw new Exception("Output file directory " + direc(outputFilename) + " does not exist!");
	MessageBox.Show("output filename ok");
	StreamWriter sw;
	try
	{
		sw = new StreamWriter(outputFilename);
	}
	catch
	{
		throw new Exception("Unspecified error");
	}
	MessageBox.Show("sw setup");
	// . . .

The "output filename ok" dialog comes up, but then nothing. The program doesn't crash, the exception doesn't occur, the "sw setup" dialog doesn't appear.

The output filename, for what it's worth, is in the user's AppData folder, so I don't think this should be a problem even with Vista's UAC, but I might be missing something obvious.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 5 ·
Replies
5
Views
9K