Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Design / Util / FileReader.cs / 1305376 / FileReader.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.MobileControls.Util { using System; using System.Diagnostics; using System.Net; using System.IO; [ System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode) ] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] internal class FileReader { // Helper class should not be instantiated. private FileReader() { } ////// This method reads a file specified by a uri and returns it /// as a byte array. If the file is located on the local file /// system, a FileStream is used instead of a WebRequest. /// internal static Byte[] Read(Uri uri) { int length; Stream stream; Byte[] buffer = null; try { WebRequest request = WebRequest.Create(uri); WebResponse response = request.GetResponse(); length = (int) response.ContentLength; stream = response.GetResponseStream(); buffer = new Byte[length]; stream.Read(buffer, 0, length); stream.Close(); } catch(Exception e) { Debug.Fail("FileReader - Unable to read url '" + uri.ToString() + ":\r\n" + e.ToString()); return null; } return buffer; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.MobileControls.Util { using System; using System.Diagnostics; using System.Net; using System.IO; [ System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode) ] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] internal class FileReader { // Helper class should not be instantiated. private FileReader() { } ////// This method reads a file specified by a uri and returns it /// as a byte array. If the file is located on the local file /// system, a FileStream is used instead of a WebRequest. /// internal static Byte[] Read(Uri uri) { int length; Stream stream; Byte[] buffer = null; try { WebRequest request = WebRequest.Create(uri); WebResponse response = request.GetResponse(); length = (int) response.ContentLength; stream = response.GetResponseStream(); buffer = new Byte[length]; stream.Read(buffer, 0, length); stream.Close(); } catch(Exception e) { Debug.Fail("FileReader - Unable to read url '" + uri.ToString() + ":\r\n" + e.ToString()); return null; } return buffer; } } } // 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
- AuthorizationSection.cs
- PerformanceCounter.cs
- Block.cs
- ObservableCollection.cs
- CellParagraph.cs
- PropertyEmitterBase.cs
- Int16Storage.cs
- BatchParser.cs
- WebServiceHandlerFactory.cs
- StyleXamlTreeBuilder.cs
- WebPartMinimizeVerb.cs
- RequestResizeEvent.cs
- CreateUserWizard.cs
- StructuralComparisons.cs
- CompatibleComparer.cs
- WebControlParameterProxy.cs
- ToolStripDropDownClosingEventArgs.cs
- DynamicPropertyReader.cs
- RSAOAEPKeyExchangeDeformatter.cs
- UnsafeNativeMethods.cs
- SymmetricKey.cs
- CreateParams.cs
- UpdatableGenericsFeature.cs
- DataGridPageChangedEventArgs.cs
- TraceListener.cs
- sqlinternaltransaction.cs
- DefaultEvaluationContext.cs
- DataGridViewRowCollection.cs
- Rotation3DKeyFrameCollection.cs
- ConfigXmlWhitespace.cs
- XmlComplianceUtil.cs
- BuildProviderAppliesToAttribute.cs
- TextElementEditingBehaviorAttribute.cs
- DataObjectPastingEventArgs.cs
- Vector3DKeyFrameCollection.cs
- FamilyMap.cs
- DataGridViewBand.cs
- HostedElements.cs
- SortQueryOperator.cs
- CLSCompliantAttribute.cs
- ScriptRef.cs
- SqlProviderManifest.cs
- SqlDuplicator.cs
- WorkflowRuntimeService.cs
- ImageBrush.cs
- D3DImage.cs
- AspNetCacheProfileAttribute.cs
- Crc32Helper.cs
- MimeMapping.cs
- LinearGradientBrush.cs
- Setter.cs
- ProvidePropertyAttribute.cs
- DockAndAnchorLayout.cs
- ResourceSet.cs
- UpdateManifestForBrowserApplication.cs
- CodeAccessSecurityEngine.cs
- MemoryMappedFile.cs
- RunClient.cs
- CompositeCollectionView.cs
- DynamicExpression.cs
- StorageModelBuildProvider.cs
- ProjectionPlan.cs
- ValueExpressions.cs
- SimpleBitVector32.cs
- StreamAsIStream.cs
- Timer.cs
- ComplexPropertyEntry.cs
- ConfigXmlElement.cs
- TripleDES.cs
- UriWriter.cs
- ScrollBar.cs
- PrintPageEvent.cs
- Mapping.cs
- SignHashRequest.cs
- HtmlTitle.cs
- Message.cs
- SiteMapNodeItem.cs
- WithParamAction.cs
- LinqDataSourceValidationException.cs
- Tracking.cs
- Equal.cs
- ExplicitDiscriminatorMap.cs
- PropertyTabChangedEvent.cs
- Marshal.cs
- UserPersonalizationStateInfo.cs
- UIElement3D.cs
- MemberInfoSerializationHolder.cs
- MediaEntryAttribute.cs
- DataGridLengthConverter.cs
- DrawingServices.cs
- RC2CryptoServiceProvider.cs
- PrePrepareMethodAttribute.cs
- WebScriptMetadataMessage.cs
- RepeaterItemCollection.cs
- SchemaTableColumn.cs
- SizeConverter.cs
- EnumDataContract.cs
- SqlUnionizer.cs
- SimpleBitVector32.cs
- SqlError.cs