.net

Directory.GetFiles finds nonexisting files

烂漫一生 提交于 2021-02-06 09:53:37
问题 I just stumbled upon an undocumented behavior of the GetFiles methods in System.IO.Directory . Whenever the searchPattern parameter passed to the method contains a reserved Windows device name, such as "nul.*" or "aux.bmp" , the method returns an array containing the name of a nonexisting file, like C:\Users\ft1\nul or D:\aux , etc. I wonder if those device names have a special meaning it that context, like "." or "..", or if this is just a sort of bug. Anyway, that still seems pretty weird.

Directory.GetFiles finds nonexisting files

浪子不回头ぞ 提交于 2021-02-06 09:53:25
问题 I just stumbled upon an undocumented behavior of the GetFiles methods in System.IO.Directory . Whenever the searchPattern parameter passed to the method contains a reserved Windows device name, such as "nul.*" or "aux.bmp" , the method returns an array containing the name of a nonexisting file, like C:\Users\ft1\nul or D:\aux , etc. I wonder if those device names have a special meaning it that context, like "." or "..", or if this is just a sort of bug. Anyway, that still seems pretty weird.

Directory.GetFiles finds nonexisting files

对着背影说爱祢 提交于 2021-02-06 09:53:21
问题 I just stumbled upon an undocumented behavior of the GetFiles methods in System.IO.Directory . Whenever the searchPattern parameter passed to the method contains a reserved Windows device name, such as "nul.*" or "aux.bmp" , the method returns an array containing the name of a nonexisting file, like C:\Users\ft1\nul or D:\aux , etc. I wonder if those device names have a special meaning it that context, like "." or "..", or if this is just a sort of bug. Anyway, that still seems pretty weird.

Using a TemplateBinding in ControlTemplate.Triggers

夙愿已清 提交于 2021-02-06 09:50:53
问题 Why does the following piece of XAML give me a XamlParseException with the (meaningless) message "Expression type is not a valid Style value." at runtime? <Control x:Class="TestApp.Max.MyControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Max="clr-namespace:TestApp.Max" mc

Will my compiler ignore useless code?

大兔子大兔子 提交于 2021-02-06 09:36:26
问题 I've been through a few questions over the network about this subject but I didn't find any answer for my question, or it's for another language or it doesn't answer totally (dead code is not useless code) so here's my question: Is (explicit or not) useless code ignored by the compiler? For example, in this code: double[] TestRunTime = SomeFunctionThatReturnDoubles; // A bit of code skipped int i = 0; for (int j = 0; j < TestRunTime.Length; j++) { } double prevSpec_OilCons = 0; will the for

Showing Print Preview in C#

混江龙づ霸主 提交于 2021-02-06 09:13:08
问题 Right now, I'm trying to build my form on a PrintDocument, but the only way for me to see where stuff is actually appearing on the page is to print a paper. It works, but I have a lot of stuff I need to add, and I'd rather not waste tons of paper. Right now I have a print dialogue come up, but theres no print preview button. Is there a way I can make one appear? Thanks! public partial class Form4 : System.Windows.Forms.Form { private System.ComponentModel.Container components; private System

Showing Print Preview in C#

梦想与她 提交于 2021-02-06 09:09:59
问题 Right now, I'm trying to build my form on a PrintDocument, but the only way for me to see where stuff is actually appearing on the page is to print a paper. It works, but I have a lot of stuff I need to add, and I'd rather not waste tons of paper. Right now I have a print dialogue come up, but theres no print preview button. Is there a way I can make one appear? Thanks! public partial class Form4 : System.Windows.Forms.Form { private System.ComponentModel.Container components; private System

Socket.IOControl - Ambiguous Documentation

主宰稳场 提交于 2021-02-06 09:08:35
问题 I tried - for the first time - to control a socket by such a low level way Walking through tutorial, I faced these lines : byte[] byTrue = new byte [4] {1, 0, 0, 0}; byte[] byOut = new byte [4] {1, 0, 0, 0}; _Socket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut); I referred to the MSDN documentation, but it's really very ambiguous. Question: What are these 2 bytes' arrays? What are they used in? The documentation says OPTIONS - what options? 回答1: The byte array arguments to Socket

Socket.IOControl - Ambiguous Documentation

空扰寡人 提交于 2021-02-06 09:07:01
问题 I tried - for the first time - to control a socket by such a low level way Walking through tutorial, I faced these lines : byte[] byTrue = new byte [4] {1, 0, 0, 0}; byte[] byOut = new byte [4] {1, 0, 0, 0}; _Socket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut); I referred to the MSDN documentation, but it's really very ambiguous. Question: What are these 2 bytes' arrays? What are they used in? The documentation says OPTIONS - what options? 回答1: The byte array arguments to Socket

Socket.IOControl - Ambiguous Documentation

这一生的挚爱 提交于 2021-02-06 09:05:48
问题 I tried - for the first time - to control a socket by such a low level way Walking through tutorial, I faced these lines : byte[] byTrue = new byte [4] {1, 0, 0, 0}; byte[] byOut = new byte [4] {1, 0, 0, 0}; _Socket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut); I referred to the MSDN documentation, but it's really very ambiguous. Question: What are these 2 bytes' arrays? What are they used in? The documentation says OPTIONS - what options? 回答1: The byte array arguments to Socket