The physical path for files

How do I get the physical path for files stored on disk? Etc c:/project/files/media/abc/as3/asd/asdasdasdasd

Litium version: 7.2

Why do you need to have the physical file path? Without knowing what you try to do it is hard to guide you in the correct direction.

We want to delete files that are not listed in media arrive.

The physical files is deleted when the file is removed.

The physical path is created from the blob uri that exists on the file entity.

We have about >80Gb that is not deleted due to update to a different database that dose not have the ref to the files.

The logic to create the path is the following logic, the uri variable is the File.BlobUri and the _folderConfig.Value.Shared is the common files directory.

            private const string _schema = "litium.blob";

            if (uri.Scheme.Equals(_schema, StringComparison.OrdinalIgnoreCase))
            {
                var id = uri.Segments[1];
                var path = Path.Combine(_folderConfig.Value.Shared, uri.Authority, Path.Combine(Enumerable.Range(0, (id.Length / 3) - 1).Select(i => id.Substring(i * 3, 3)).ToArray()), id);
            }

            if (uri.Scheme.StartsWith($"{_schema}+storage", StringComparison.OrdinalIgnoreCase))
            {
                var path = Path.Combine(_folderConfig.Value.Shared, "Storage", uri.Authority, Path.Combine(uri.Segments.Skip(1).Select(x => x.Trim('/')).ToArray()));
            }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.