TileCook.DiskCache.Put C# (CSharp) Method

Put() public method

public Put ( Coord coord, string format, byte image ) : void
coord Coord
format string
image byte
return void
        public void Put(Coord coord, string format, byte[] image)
        {
            string path = this.buildPath(coord, format);
            int i = 0;
            while (true)
            {
                try
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                    File.WriteAllBytes(path, image);
                    break;
                }
                catch (IOException e)
                {
                    //is file being written? check for ERROR_SHARING_VIOLATION (HRESULT = -2147024864)
                    //.NET 4.5 required to access HResult directly
                    if (e.HResult == -2147024864 && i <= ACCESS_POLL_COUNT)
                    {
                        i++;
                        Thread.Sleep(ACCESS_POLL_INTERVAL);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }