In .NET 1.1 , If you write code like this
Cache.Add("key",DateTime.Now.ToString(),new System.Web.Caching.CacheDependency(@"C:/Common.config"),System.Web.Caching.Cache.NoAbsoluteExpiration,System.Web.Caching.Cache.NoSlidingExpiration,System.Web.Caching.CacheItemPriority.Default,null);
please pay attention to the filename, even this file path is valid and you will always get the error that say invalid file name for monitoring.
So what happend? Permission? Or Any IIS Lock Software?
hehe, the problem is the you must write a valid file path like \\Server\A.txt
or C:\\Yourfile.path , So the problem is that .NEt 1.1 determine the file path via the following code
internal static bool IsAbsolutePhysicalPath(string path)
{
if ((path != null) && (path.Length >= 3))
{
if (path.StartsWith(@"\\"))
{
return true;
}
if (char.IsLetter(path[0]) && (path[1] == ':'))
{
return (path[2] == '\\');
}
}
return false;
}
So change your filepath to C:\Common.config will ease the exception.ha .
this issue has been fixed in .net 2.0,here is the code
internal static bool IsAbsolutePhysicalPath(string path)
{
if ((path == null) || (path.Length < 3))
{
return false;
}
if ((path[1] == ':') && UrlPath.IsDirectorySeparatorChar(path[2]))
{
return true;
}
return UrlPath.IsUncSharePath(path);
}
which char is a valid directory separator? like thi
private static bool IsDirectorySeparatorChar(char ch)
{
if (ch != '\\')
{
return (ch == '/');
}
return true;
}