Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / ComponentModel / SyntaxCheck.cs / 1305376 / 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
- DataGrid.cs
- ToolboxComponentsCreatingEventArgs.cs
- COM2IDispatchConverter.cs
- ServiceModelConfiguration.cs
- UnaryNode.cs
- CardSpaceException.cs
- TextBox.cs
- arc.cs
- DecimalAnimationUsingKeyFrames.cs
- XmlNodeChangedEventManager.cs
- SafePointer.cs
- DigitShape.cs
- AttachmentCollection.cs
- TokenBasedSetEnumerator.cs
- XmlSchema.cs
- FormView.cs
- RepeatButton.cs
- Point3DKeyFrameCollection.cs
- HttpHandlerActionCollection.cs
- TemplateBindingExtensionConverter.cs
- PropertyDescriptorCollection.cs
- XmlNodeReader.cs
- XomlSerializationHelpers.cs
- IntSecurity.cs
- HostingEnvironmentException.cs
- SubMenuStyle.cs
- ImageInfo.cs
- recordstatescratchpad.cs
- CompatibleComparer.cs
- PolyLineSegment.cs
- DictionaryTraceRecord.cs
- COM2PropertyBuilderUITypeEditor.cs
- XmlSchemaAll.cs
- MailMessage.cs
- PowerStatus.cs
- CatalogPartCollection.cs
- storepermissionattribute.cs
- PrinterResolution.cs
- RuntimeHelpers.cs
- InternalSafeNativeMethods.cs
- Solver.cs
- DefaultPrintController.cs
- TraceHwndHost.cs
- ToolStripTextBox.cs
- MetabaseSettingsIis7.cs
- CommonEndpointBehaviorElement.cs
- ToolBar.cs
- AuthorizationSection.cs
- NCryptSafeHandles.cs
- PersonalizationProviderCollection.cs
- TypeProvider.cs
- HierarchicalDataBoundControlAdapter.cs
- DoubleLinkList.cs
- PropertiesTab.cs
- PriorityBinding.cs
- CodePrimitiveExpression.cs
- DetailsViewDeletedEventArgs.cs
- BinaryWriter.cs
- WebConfigManager.cs
- RoleGroupCollection.cs
- UrlPropertyAttribute.cs
- TextTreeTextBlock.cs
- PortCache.cs
- EDesignUtil.cs
- EntityParameterCollection.cs
- WebPartRestoreVerb.cs
- JsonGlobals.cs
- RowUpdatingEventArgs.cs
- X509CertificateClaimSet.cs
- ToolStripItemClickedEventArgs.cs
- ListViewEditEventArgs.cs
- DbInsertCommandTree.cs
- ScaleTransform.cs
- TransformerTypeCollection.cs
- Walker.cs
- DesignTimeVisibleAttribute.cs
- LinkedResourceCollection.cs
- AutoCompleteStringCollection.cs
- DataStorage.cs
- DataGridViewToolTip.cs
- TextReader.cs
- CookielessHelper.cs
- FixedSOMTableCell.cs
- IsolatedStorageFileStream.cs
- DataGridColumnCollection.cs
- ClassGenerator.cs
- DataGridTable.cs
- ToolStripItemDesigner.cs
- XmlAttributeHolder.cs
- UnaryNode.cs
- DbFunctionCommandTree.cs
- QilLoop.cs
- ObjectListShowCommandsEventArgs.cs
- IsolatedStoragePermission.cs
- RangeBaseAutomationPeer.cs
- QueryableDataSourceView.cs
- NegatedCellConstant.cs
- CollectionViewSource.cs
- Win32SafeHandles.cs
- RunInstallerAttribute.cs