Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / ComponentModel / SyntaxCheck.cs / 1 / SyntaxCheck.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.ComponentModel { using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Security.Permissions; ////// /// SyntaxCheck /// Helper class to check for path and machine name syntax. /// [HostProtection(SharedState = true)] public static class SyntaxCheck { ////// Checks the syntax of the machine name (no "\" anywhere in it). /// ///public static bool CheckMachineName(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Machine names shouldn't contain any "\" return (value.IndexOf('\\') == -1); } /// /// Checks the syntax of the path (must start with "\\"). /// ///public static bool CheckPath(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Path names should start with "\\" return value.StartsWith("\\\\"); } /// /// Checks the syntax of the path (must start with "\" or drive letter "C:"). /// NOTE: These denote a file or directory path!! /// /// ///public static bool CheckRootedPath(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Is it rooted? return Path.IsPathRooted(value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.ComponentModel { using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Security.Permissions; ////// /// SyntaxCheck /// Helper class to check for path and machine name syntax. /// [HostProtection(SharedState = true)] public static class SyntaxCheck { ////// Checks the syntax of the machine name (no "\" anywhere in it). /// ///public static bool CheckMachineName(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Machine names shouldn't contain any "\" return (value.IndexOf('\\') == -1); } /// /// Checks the syntax of the path (must start with "\\"). /// ///public static bool CheckPath(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Path names should start with "\\" return value.StartsWith("\\\\"); } /// /// Checks the syntax of the path (must start with "\" or drive letter "C:"). /// NOTE: These denote a file or directory path!! /// /// ///public static bool CheckRootedPath(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Is it rooted? return Path.IsPathRooted(value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DateTimeOffsetConverter.cs
- CompiledWorkflowDefinitionContext.cs
- SecurityDocument.cs
- SerializationSectionGroup.cs
- InvalidComObjectException.cs
- FaultException.cs
- XmlCDATASection.cs
- WindowsListViewItemStartMenu.cs
- ActivationArguments.cs
- SessionStateModule.cs
- TypeConverterHelper.cs
- JsonFaultDetail.cs
- MimeWriter.cs
- SamlAuthorizationDecisionClaimResource.cs
- RsaSecurityToken.cs
- LineVisual.cs
- DispatchOperation.cs
- DataGridViewSortCompareEventArgs.cs
- TextBox.cs
- SqlNotificationRequest.cs
- UnsafeNativeMethodsPenimc.cs
- PathTooLongException.cs
- TextTreeFixupNode.cs
- _ConnectionGroup.cs
- CharacterMetrics.cs
- Triplet.cs
- PointF.cs
- ChildTable.cs
- SchemaCollectionPreprocessor.cs
- XmlChoiceIdentifierAttribute.cs
- Bold.cs
- PositiveTimeSpanValidator.cs
- Blend.cs
- Base64Encoder.cs
- EncryptedData.cs
- BrowserDefinition.cs
- SafeProcessHandle.cs
- ButtonBaseAutomationPeer.cs
- DisplayInformation.cs
- DataGrid.cs
- SourceFilter.cs
- DSASignatureFormatter.cs
- PDBReader.cs
- PackagingUtilities.cs
- SafeCoTaskMem.cs
- DocumentEventArgs.cs
- XhtmlBasicLinkAdapter.cs
- UICuesEvent.cs
- LocalFileSettingsProvider.cs
- StyleBamlRecordReader.cs
- CapabilitiesPattern.cs
- SubstitutionList.cs
- PersonalizationProvider.cs
- TextEncodedRawTextWriter.cs
- SqlConnectionManager.cs
- MsmqInputChannel.cs
- ProjectionQueryOptionExpression.cs
- FileDialogCustomPlace.cs
- DateTimeOffsetConverter.cs
- XmlSchemaAnnotated.cs
- BrowserDefinitionCollection.cs
- XmlLanguageConverter.cs
- DataFormat.cs
- ProfileEventArgs.cs
- PathGradientBrush.cs
- DNS.cs
- AttributeQuery.cs
- AnonymousIdentificationModule.cs
- CompositeFontParser.cs
- BStrWrapper.cs
- CompoundFileIOPermission.cs
- DeviceContext.cs
- SymbolEqualComparer.cs
- Debug.cs
- EnumMember.cs
- OracleColumn.cs
- FunctionDescription.cs
- ObjectDataSourceDisposingEventArgs.cs
- MobileControlsSectionHelper.cs
- BinaryNode.cs
- UnsafeNativeMethods.cs
- PublisherMembershipCondition.cs
- TypeCollectionDesigner.xaml.cs
- TreeViewCancelEvent.cs
- ValidationPropertyAttribute.cs
- xdrvalidator.cs
- JulianCalendar.cs
- SynchronousSendBindingElement.cs
- ParameterBuilder.cs
- UiaCoreProviderApi.cs
- webeventbuffer.cs
- TreeIterator.cs
- PathTooLongException.cs
- PrinterSettings.cs
- Int16AnimationUsingKeyFrames.cs
- SpotLight.cs
- EmptyTextWriter.cs
- WpfWebRequestHelper.cs
- AnonymousIdentificationSection.cs
- ParallelEnumerableWrapper.cs