示例#1
0
        private static string GetFullPathAndValidateCase(LanguageContext /*!*/ context, string path, bool isDir)
        {
#if !SILVERLIGHT
            // check for a match in the case of the filename, unfortunately we can't do this
            // in Silverlight becauase there's no way to get the original filename.

            PlatformAdaptationLayer pal = context.DomainManager.Platform;
            string dir = pal.GetDirectoryName(path);
            if (!pal.DirectoryExists(dir))
            {
                return(null);
            }

            try {
                string   file  = pal.GetFileName(path);
                string[] files = pal.GetFileSystemEntries(dir, file, !isDir, isDir);

                if (files.Length != 1 || pal.GetFileName(files[0]) != file)
                {
                    return(null);
                }

                return(pal.GetFullPath(files[0]));
            } catch (IOException) {
                return(null);
            }
#else
            return(path);
#endif
        }
示例#2
0
        private static string GetFullPathAndValidateCase(LanguageContext /*!*/ context, string path, bool isDir)
        {
            // Check for a match in the case of the filename.
            PlatformAdaptationLayer pal = context.DomainManager.Platform;
            string dir = pal.GetDirectoryName(path);

            if (!pal.DirectoryExists(dir))
            {
                return(null);
            }

            try {
                string   file  = pal.GetFileName(path);
                string[] files = pal.GetFileSystemEntries(dir, file, !isDir, isDir);

                if (files.Length != 1 || pal.GetFileName(files[0]) != file)
                {
                    return(null);
                }

                return(pal.GetFullPath(files[0]));
            } catch (IOException) {
                return(null);
            }
        }