Limitations of file in web


There are several limitations to files:

File-naming limitations:When we create a new file, it obviously can’t have the same name as an existing file in the same directory. That means we’ll probably need to fall back on some system for randomly generating files names. For example, we might create a file name based on a random number combined with the current date and time, or create a file name that incorporates a GUID (globally unique identifier). With both of these approaches, file names would be statistically unique, which means duplicates would be extremely unlikely. However, the file names wouldn’t be very meaningful. In databases,
this problem is solved more neatly with the auto-increment data type, which automatically fills a specific field with a unique number when we create a record.

Multiuser limitations: Relational databases provide features like locking and transactions to prevent inconsistencies and make sure multiple people can use the same data at the same time. Comparatively, the web server’s file system is woefully backward. Although we can allow multiple users to read a file at once, it’s almost impossible to let multiple users update the same file at the same time without catastrophe.

Scalability problems: File operations suffer from some overhead. In a simple scenario, file access may be faster than connecting to a database and performing a query. But the cumulative effect in a large web application is very different. When multiple users are working with files at the same time, our web server may slow down dramatically.

Security risks: If we allow the user to specify a file or path name, the user could devise a way to trick our application into accessing or overwriting a protected system file. Even without this ability, a malicious or careless user might use an ASP.NET page that creates
or uploads files to fill up our web server hard drive and cause it to stop working. All of these problems are preventable, but they require a bit more work than a database-backed solution.

File system information

.NET provides five basic classes for retrieving this sort of information. They are all located in the System.IO namespace (and, incidentally, can be used in desktop applications in exactly the same way they are used in web applications). They include the following:
• The Directory and File classes, which provide static methods that allow us to retrieve information about any files and directories visible from our server
• The DirectoryInfo and FileInfo classes, which use similar instance methods and properties to retrieve the same sort of information
• The DriveInfo class, which provides static methods that allow us to retrieve information about a drive and the amount of free space it provides