本文整理汇总了C#中VirtualPath.FileExists方法的典型用法代码示例。如果您正苦于以下问题:C# VirtualPath.FileExists方法的具体用法?C# VirtualPath.FileExists怎么用?C# VirtualPath.FileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualPath
的用法示例。
在下文中一共展示了VirtualPath.FileExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckVirtualFileExists
internal static void CheckVirtualFileExists(VirtualPath virtualPath) {
if (!virtualPath.FileExists()) {
throw new HttpException(
HttpStatus.NotFound,
SR.GetString(SR.FileName_does_not_exist,
virtualPath.VirtualPathString));
}
}
示例2: VirtualFileExistsWithAssert
internal static bool VirtualFileExistsWithAssert(VirtualPath virtualPath) {
string physicalDir = virtualPath.MapPathInternal();
if (physicalDir != null) {
(InternalSecurityPermissions.PathDiscovery(physicalDir)).Assert();
}
return virtualPath.FileExists();
}
示例3: GetVPathBuildResultInternal
private BuildResult GetVPathBuildResultInternal(VirtualPath virtualPath, bool noBuild, bool allowCrossApp, bool allowBuildInPrecompile, bool throwIfNotFound, bool ensureIsUpToDate = true) {
Debug.Trace("BuildManager", "GetBuildResult(" + virtualPath + ")");
// This should never be called while building top level files (VSWhidbey 480256)
if (_compilationStage == CompilationStage.TopLevelFiles) {
throw new HttpException(SR.GetString(SR.Too_early_for_webfile, virtualPath));
}
// Make sure the path is not relative
Debug.Assert(!virtualPath.IsRelative);
// Try the cache first before getting the mutex
BuildResult result = GetVPathBuildResultFromCacheInternal(virtualPath, ensureIsUpToDate);
if (result != null)
return result;
// If we were only checking the cache and it wasn't there, return null.
if (noBuild)
return null;
// Check if it's trying to go cross app, or points to a special directory.
// It's important to do this before checkin existence, to avoid revealing information
// about other apps (VSWhidbey 442632)
ValidateVirtualPathInternal(virtualPath, allowCrossApp, false /*codeFile*/);
if (throwIfNotFound) {
// Before grabbing the lock, make sure the file at least exists (ASURT 46465)
Util.CheckVirtualFileExists(virtualPath);
}
else if (!virtualPath.FileExists()) {
return null;
}
// If this is a precompiled app, complain if we couldn't find it in the cache
if (IsNonUpdatablePrecompiledApp && !allowBuildInPrecompile) {
throw new HttpException(
SR.GetString(SR.Cant_update_precompiled_app, virtualPath));
}
bool gotLock = false;
try {
// Grab the compilation mutex
CompilationLock.GetLock(ref gotLock);
// Check the cache a second time after getting the mutex
result = GetVPathBuildResultFromCacheInternal(virtualPath, ensureIsUpToDate);
if (result != null)
return result;
// Get the circular reference checker (create it if needed)
VirtualPathSet circularReferenceChecker;
circularReferenceChecker = CallContext.GetData(CircularReferenceCheckerSlotName)
as VirtualPathSet;
if (circularReferenceChecker == null) {
circularReferenceChecker = new VirtualPathSet();
// Create it and save it in the CallContext
CallContext.SetData(CircularReferenceCheckerSlotName, circularReferenceChecker);
}
// If a circular reference is detected, throw an error
if (circularReferenceChecker.Contains(virtualPath)) {
throw new HttpException(
SR.GetString(SR.Circular_include));
}
// Add the current virtualPath to the circular reference checker
circularReferenceChecker.Add(virtualPath);
try {
//
EnsureTopLevelFilesCompiled();
result = CompileWebFile(virtualPath);
}
finally {
// Remove the current virtualPath from the circular reference checker
Debug.Assert(circularReferenceChecker.Contains(virtualPath));
circularReferenceChecker.Remove(virtualPath);
}
}
finally {
// Always release the mutex if we had taken it
if (gotLock) {
CompilationLock.ReleaseLock();
}
}
return result;
}