Ejemplo n.º 1
0
        public static FileStream ToWriteStream(this FileInfo obj,
                                               FileMode mode)
#endif
        {
            if (null == obj)
            {
                throw new ArgumentNullException("obj");
            }

#if NET20
            if (!GenericExtensionMethods.In(mode,
#else
            if (!mode.In(
#endif
                                            FileMode.Create,
                                            FileMode.CreateNew,
                                            FileMode.Append,
                                            FileMode.Truncate))
            {
                throw new ArgumentOutOfRangeException("mode");
            }

            return(obj.Open(mode, FileAccess.Write, FileShare.Read));
        }
Ejemplo n.º 2
0
        public static FileStream ToWriteStream(this FileInfo obj,
                                               FileMode mode)
#endif
        {
            if (null == obj)
            {
                throw new ArgumentNullException("obj");
            }

#if NET20
            if (!GenericExtensionMethods.In(mode,
#else
            if (!mode.In(
#endif
                     FileMode.Create,
                     FileMode.CreateNew,
                     FileMode.Append,
                     FileMode.Truncate))
            {
                throw new ArgumentOutOfRangeException("mode");
            }

            return obj.Open(mode, FileAccess.Write, FileShare.Read);
        }