///
/// This function will create an image with from the given filename
///
public class MyFile
{
... the rest of code
Developing with CSharp many time you feel a strange feeling... then feeling of lost and how to solve it. Fortunately MSDN has done a good work to help the developers. .net offers thousand ways to do several things! This is the worst thing… because, you do not know where to start from and what works in real world! I hope to help you with your CSharpache.
| You are familiar with many of Visual Studio's shortcut keys, but not all of them. Here is a handy reference that can make your .NET lifestyle easier and a lot more productive. The 'must-know' shortcut keys are highlighted. | |
| Shortcut | Description |
| Ctrl-X or Shift-Delete | Cuts the currently selected item to the clipboard |
| Ctrl-C or Ctrl-Insert | Copies the currently selected item to the clipboard |
| Ctrl-V or Shift-Insert | Pastes the item in the clipboard at the cursor |
| Ctrl-Z or Alt-Backspace | Undo previous editing action |
| Ctrl-Y or Ctrl-Shift-Z | Redo the previous undo action |
| Ctrl-Shift-V or Ctrl-Shift-Insert | Pastes an item from the clipboard ring tab of the Toolbox at the cursor in the file and automatically selects the pasted item. Cycle through the items on the clipboard by pressing the shortcut keys repeatedly |
| Esc | Closes a menu or dialog, cancels an operation in progress, or places focus in the current document window |
| Ctrl-S | Saves the selected files in the current project (usually the file that is being edited) |
| Ctrl-Shift-S | Saves all documents and projects |
| Ctrl-P | Displays the Print dialog |
| F7 | Switches from the design view to the code view in the editor |
| Shift-F7 | Switches from the code view to the design view in the editor |
| F8 | Moves the cursor to the next item, for example in the TaskList window or Find Results window |
| Shift-F8 | Moves the cursor to the previous item, for example in the TaskList window or Find Results window |
| Shift-F12 | Finds a reference to the selected item or the item under the cursor |
| Ctrl-Shift-G | Opens the file whose name is under the cursor or is currently selected |
| Ctrl-/ | Switches focus to the Find/Command box on the Standard toolbar |
| Ctrl-Shift-F12 | Moves to the next task in the TaskList window |
| Ctrl-Shift-8 | Moves backward in the browse history. Available in the object browser or Class View window |
| Alt-Left Arrow | Go back in the web browser history |
| Alt-Right Arrow | Go forward in the web browser history |
| problem | |
| c# idiot fucken error!!! (microsoft SUCKS) --------------------------- The current project settings specify that the project will be debugged with specific security permissions. In this mode, command line arguments will not be passed to the executable. Do you want to continue debugging anyway? [Yes] [No] --------------------------- | |
| difficulty level | |
| 3/10 :| | |
| compatibility | |
| vs2008 .net 2.5 | |
| solution | |
| - open the properties of the application - go to at security tab - click "Enable ClickOnce security settings" - select "This is a partial trust" (at the end you may turn it back) - Under all these, there is a button "Advanced" where it is not displayed sometimes if your monitor has lo resolution, scroll down to see it, press it and there you may find the settings if you with to use this "permission set" on debug execution. If you selected to use this settings you cannot use the specified command line arguments at "debug" tab of the parameters (one more reason why Microsoft sucks). Your application will use the command line arguments finally in "release" version. Who fucks Microsoft anyway, add some code to feed your application with the command line argument from inside your code. This is not so professional but with Microsoft we can't be professionals anyway! - SAVE the parameters window and then ReBuild! | |
problem | |
c# security fucken error!!! (microsoft SUCKS) --------------------------- Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. | |
difficulty level | |
3/10 :| | |
compatibility | |
vs2008 .net 2.5 | |
solution | |
- be sure that the file you are trying to open it from you code, is in the same directory or somewhere where is valid to reach- open the properties of the application - go to at security tab - click "Enable ClickOnce security settings" - select "This is a partial trust" - Zone your application: (custom) - Select above all the secutiry settings required from the environment where the application will run (consider about this!). You must include FileIOPermission if your application open files. Do not include regardless permissions because in case where the end user hasn't them (i.e. guest user) your application will not run. - Under all these, there is a button "Advanced" where it is not displayed sometimes if your monitor has lo resolution, scroll down to see it, press it and there you may find the settings if you with to use this "permission set" on debug execution. If you selected to use this settings you cannot use the specified arguments at "debug" tab of the parameters (one more reason why Microsoft sucks). Your application will use the command line arguments finally in "release" version. - SAVE the parameters window and then ReBuild! - open the file c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config ; this key and update accordingly: <trust level="Full" originUrl=""/> | |
problem | |
c# - how to handle files, directories and drives --- Working with the File Type --- in practice! >>guide<< | |
difficulty level | |
3/10 :| | |
compatibility | |
flex 4.0 | |
solution | |
Method Meaning in Life ReadAllBytes() Opens the specified file, returns the binary data as an array of bytes, and then closes the file ReadAllLines() Opens a specified file, returns the character data as an array of strings, and then closes the file ReadAllText() Opens a specified file, returns the character data as a System.String, and then closes the file WriteAllBytes() Opens the specified file, writes out the byte array, and then closes the file WriteAllLines() Opens a specified file, writes out an array of strings, and then closes the file WriteAllText() Opens a specified file, writes the character data, and then closes the file Using these new methods of the File type, you are able to read and write batches of data in just a few lines of code. Even better, each of these new members automatically closes down the underlying file handle. For example, the following console program (named SimpleFileIO) will persist the string data into a new file on the C drive (and read it into memory) with minimal fuss: using System; using System.IO; // important! class Program { static void Main(string[] args) { Console.WriteLine("***** Simple IO with the File Type *****\n"); string[] myTasks = { "Fix bathroom sink", "Call Dave", "Call Mom and Dad", "Play Xbox 360"}; // Write out all data to file on C drive. File.WriteAllLines(@"C:\tasks.txt", myTasks); // Read it all back and print out. foreach (string task in File.ReadAllLines(@"C:\tasks.txt")) Console.WriteLine("TODO: {0}", task); Console.ReadLine(); } } | |